Re: [sqlite] Compiling spellfix for sqlite3

2017-08-26 Thread curmudgeon
Thanks for those explanations Keith and Richard. I always thought the <> were
the ones supplied by the language.



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97122.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-25 Thread Richard Damon

On 8/25/17 2:15 PM, Keith Medcalf wrote:

When the included file is in " " then the file is expected to be located relative to the current directory.  If the 
included file is in < > then it is relative to one of the directories specified in the "include search path".  This 
search may or may not include the "current directory" but to have "current directory" included, you have to 
specify the directory location specifically to the compiler -- it does not automatically look in the current directory for files 
included with the < > syntax.
This is incorrect. The Standard doesn't even require the that Standard 
define includes even actually be 'C files', and the header files don't 
need to be in 'directory'


What the standard does say is that includes specified with <> look in a 
set of implementation defined places, and that includes with "" look in 
another set of implementation defined places, with the addition that if 
it doesn't find them there, it looks in the places defined for <>


Generally, and traditionally, the <> list of places is thought of as the 
'system' include path, and the "" list of places are the user include 
path, and it is fairly normal that the "" list includes the current 
directory.



--
Richard Damon

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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-25 Thread Keith Medcalf

When the included file is in " " then the file is expected to be located 
relative to the current directory.  If the included file is in < > then it is 
relative to one of the directories specified in the "include search path".  
This search may or may not include the "current directory" but to have "current 
directory" included, you have to specify the directory location specifically to 
the compiler -- it does not automatically look in the current directory for 
files included with the < > syntax.

So for example, GCC sets several default search locations based on the location 
of the compiler executable itself (so it can find the headers included with the 
compiler).  It then "appends" the directories specified in the INCLUDE 
environment variable to that list.  Command line options (and compilers with 
GUI interfaces will have the same options somewhere) allow the specification of 
"prepends" and "appends" to that list of directories.  Most compilers work the 
same way.

There is also a "LIB search path" that works the same way for linking the 
object files and libraries together.  GCC has defaults set according to the 
location of the compiler executable, then appends the paths found in the LIB 
environment variable, and then has Command line (located in the GUI options for 
other compilers) that let you prepend and append additional paths to the list.

The include and lib paths work the same way for almost all compilers, though 
there are a few exceptions.  For example, there is an old Fortran compiler that 
looks specifically in the "F99INCLUDE" environment variable for included 
Fortran code (actually, anything that is not a .h file), and the "INCLUDE" 
environment variable only for .h files.  Most compilers, however, only use one 
set of "include" and "lib" paths and know how to search for the files 
specifically.

Because the INCLUDE and LIB paths are a list of multiple directories to search, 
order is important.  Only the first file found matching the specified name/type 
will be used.  (Similar to the PATH environment variable on Windows used to 
search for executables).  This is why the compiler itself will usually have a 
pre-set location list as a starting point, to ensure that those files and 
libraries specific to the compiler are used in preference to any you might add 
later.

So if you were to find a copy of zlib prebuilt for your platform and compiler 
you would get at least a .h and .lib (headers and pre-compiled library file).  
You can stick those anywhere you like and add the directory where you put then 
to the INCLUDE search path (so the #include  will find it) and the LIB 
path (so you can specify that Z.LIB or whatever it is named for you) can be 
located when you add the z.lib library to be linked to your project.

In many cases these path additions are done by adding them (and may be done 
automatically for you when you install the library) to the INCLUDE and LIB 
environment variables.  That way whenever you need/reference the 
library/headers they will be found.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of curmudgeon
>Sent: Friday, 25 August, 2017 11:35
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Compiling spellfix for sqlite3
>
>Thanks Keith, the config info is most welcome. I wasn't sure if I was
>supposed to download zlib.h the fact it was inside <> instead of ""
>but
>understand now.
>
>Is the include  in csv.c not a bug though, or is it
>again down
>to my compiler?
>
>
>
>--
>View this message in context:
>http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-
>tp70656p97105.html
>Sent from the SQLite mailing list archive at Nabble.com.
>___
>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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-25 Thread curmudgeon
Thanks Keith, the config info is most welcome. I wasn't sure if I was
supposed to download zlib.h the fact it was inside <> instead of "" but
understand now.

Is the include  in csv.c not a bug though, or is it again down
to my compiler?



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97105.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-25 Thread Keith Medcalf
uce 
Synchronous to NORMAL in WAL mode
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS  1   // Disable LIKE 
matching for BLOBS
// #define SQLITE_MAX_EXPR_DEPTH   0   // Disable 
Parser Depth Checking
// #define SQLITE_OMIT_DECLTYPE1   // Omit 
Declaration Type from Cursors
// #define SQLITE_OMIT_DEPRECATED  1   // Omit 
Deprecated Code
// #define SQLITE_OMIT_PROGRESS_CALLBACK   1   // Omit 
Progress Callback loop counter
// #define SQLITE_OMIT_SHARED_CACHE1   // Omit 
Shared Cache

// Compiler and Platform specifics

#define HAVE_FDATASYNC 1
#define HAVE_GMTIME_R 1
#define HAVE_LOCALTIME_S 1
#define HAVE_USLEEP 1
#define HAVE_UTIME 1
#define HAVE_MALLOC_USABLE_SIZE 1

#if defined(_WIN32) && defined(__GNUC__)
#define UNICODE_STRING_MAX_BYTES ((WORD)65534)
#define UNICODE_STRING_MAX_CHARS (32766)
#define HAVE_ISNAN 1
#endif

#if defined(__GNUC__) && defined(SQLITE_USE_QUADMATH)
#define LONGDOUBLE_TYPE __float128
#endif
#endif
---//-- snip --//--

and that is how I end up with this after building the shell:

SQLite version 3.21.0 2017-08-25 13:34:18
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> pragma compile_options;
ALLOW_COVERING_INDEX_SCAN
ALLOW_URI_AUTHORITY
COMPILER=gcc-7.1.0
DEFAULT_CACHE_SIZE=262144
DEFAULT_FOREIGN_KEYS
DEFAULT_MMAP_SIZE=0
DEFAULT_PAGE_SIZE=4096
DEFAULT_PROXYDIR_PERMISSIONS=0755
DEFAULT_RECURSIVE_TRIGGERS
DEFAULT_WAL_AUTOCHECKPOINT=256
DEFAULT_WAL_SYNCHRONOUS=1
ENABLE_8_3_NAMES=1
ENABLE_API_ARMOR
ENABLE_COLUMN_METADATA
ENABLE_COSTMULT
ENABLE_CURSOR_HINTS
ENABLE_DBSTAT_VTAB
ENABLE_FTS3
ENABLE_FTS3_PARENTHESIS
ENABLE_FTS4
ENABLE_FTS5
ENABLE_JSON1
ENABLE_LOAD_EXTENSION
ENABLE_LOCKING_STYLE=1
ENABLE_MEMORY_MANAGEMENT
ENABLE_MEMSYS3
ENABLE_MEMSYS5
ENABLE_PREUPDATE_HOOK
ENABLE_RBU
ENABLE_RTREE
ENABLE_SESSION
ENABLE_STAT4
ENABLE_STMTVTAB
EXTRA_INIT=core_init
HAVE_ISNAN
LIKE_DOESNT_MATCH_BLOBS
MAX_ATTACHED=15
SOUNDEX
STAT4_SAMPLES=64
TEMP_STORE=2
THREADSAFE=1
USE_URI
WIN32_MALLOC

(the EXTRA_INIT being set separately so I can build an "unmodified" version 
without all the extra extensions for debugging ..)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of curmudgeon
>Sent: Friday, 25 August, 2017 07:41
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Compiling spellfix for sqlite3
>
>While testing I appended the following code to the end of sqlite3.c.
>
>#include "csv.c"
>#include "stmt.c"
>#include "compress.c"
>#include "eval.c"
>#include "carray.c"
>
>int core_init(const char* dummy)
>{
>   int nErr = 0;
>   nErr +=
>sqlite3_auto_extension((void(*)())sqlite3_compress_init);
>   nErr += sqlite3_auto_extension((void(*)())sqlite3_eval_init);
>#ifndef SQLITE_OMIT_VIRTUALTABLE
>   nErr += sqlite3_auto_extension((void(*)())sqlite3_csv_init);
>   nErr += sqlite3_auto_extension((void(*)())sqlite3_stmt_init);
>   nErr += sqlite3_auto_extension((void(*)())sqlite3_carray_init);
>#endif
>   return nErr ? SQLITE_ERROR : SQLITE_OK;
>}
>
>
>My compiler gave the following errors/warnings.
>
>[bcc32 Error] csv.c(42): E2209 Unable to open include file
>'sqlite3ext.h'
>I fixed this error by changing  to "sqlite3ext.h"
>
>[bcc32 Error] sqlite3.c(204450): E2451 Undefined symbol
>'sqlite3_stmt_init'
>Not sure if this is to do with the fact that stmt.c is already
>present in
>sqlite3.c
>
>[bcc32 Error] compress.c(18): E2209 Unable to open include file
>'zlib.h'
>Above error appears even if I change  to "zlib.h"
>[bcc32 Warning] compress.c(54): W8065 Call to function 'compress'
>with no
>prototype
>[bcc32 Error] compress.c(55): E2451 Undefined symbol 'Z_OK'
>[bcc32 Warning] compress.c(87): W8065 Call to function 'uncompress'
>with no
>prototype
>[bcc32 Error] compress.c(88): E2451 Undefined symbol 'Z_OK'
>
>
>
>
>
>
>--
>View this message in context:
>http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-
>tp70656p97100.html
>Sent from the SQLite mailing list archive at Nabble.com.
>___
>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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-25 Thread curmudgeon
While testing I appended the following code to the end of sqlite3.c.

#include "csv.c"
#include "stmt.c"
#include "compress.c"
#include "eval.c"
#include "carray.c"

int core_init(const char* dummy)
{
int nErr = 0;
nErr += sqlite3_auto_extension((void(*)())sqlite3_compress_init);
nErr += sqlite3_auto_extension((void(*)())sqlite3_eval_init);
#ifndef SQLITE_OMIT_VIRTUALTABLE
nErr += sqlite3_auto_extension((void(*)())sqlite3_csv_init);
nErr += sqlite3_auto_extension((void(*)())sqlite3_stmt_init);
nErr += sqlite3_auto_extension((void(*)())sqlite3_carray_init);
#endif
return nErr ? SQLITE_ERROR : SQLITE_OK;
}


My compiler gave the following errors/warnings.

[bcc32 Error] csv.c(42): E2209 Unable to open include file 'sqlite3ext.h'
I fixed this error by changing  to "sqlite3ext.h"

[bcc32 Error] sqlite3.c(204450): E2451 Undefined symbol 'sqlite3_stmt_init'
Not sure if this is to do with the fact that stmt.c is already present in
sqlite3.c

[bcc32 Error] compress.c(18): E2209 Unable to open include file 'zlib.h'
Above error appears even if I change  to "zlib.h"
[bcc32 Warning] compress.c(54): W8065 Call to function 'compress' with no
prototype
[bcc32 Error] compress.c(55): E2451 Undefined symbol 'Z_OK'
[bcc32 Warning] compress.c(87): W8065 Call to function 'uncompress' with no
prototype
[bcc32 Error] compress.c(88): E2451 Undefined symbol 'Z_OK'






--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97100.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-24 Thread Dominique Devienne
On Thu, Aug 24, 2017 at 1:24 AM, Keith Medcalf  wrote:

> >On Wed, Aug 23, 2017 at 6:11 PM, Keith Medcalf 
> wrote:
> >Where's that pragma from Keith? Thanks, --DD
>
> They were added "experimentally" on July 7, 2017


Oh cool, that's great! thanks for the heads-up.


> You will note that for example the returned rows show both the builtin and
> user-defined function names,

even though one may be overriding the other in various circumstances,

and also no differentiation between scalar functions, aggregates, and no
> flags or argument numbers/types.


I hope this is added eventually, fwiw. All that info exists in the
in-memory data-model,
so there's no reason the evtable wouldn't expose it IMHO. Then again, I've
thought for years
there's no reason SQLite didn't have this pragma either, so who knows
if/when that might come :)


> They appeared in the 3.20.0 release code although turned off by default --

you need to "build your own" with the preprocessor symbol
> SQLITE_INTROSPECTION_PRAGMAS defined.
>
> The commit to trunk can be found here:
> https://www.sqlite.org/src/info/e0b6ae92adfae46f


Thanks again for the detailed info. Cheers, --DD
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-23 Thread Keith Medcalf
On Wednesday, 23 August, 2017 16:28, Dominique Devienne  
wrote:

>On Wed, Aug 23, 2017 at 6:11 PM, Keith Medcalf  wrote:

>> sqlite> pragma function_list;
>> group_concat|1
>> group_concat|1
>> julianday|1
>> julianday|1
>> nullif|1
>> nullif|1
>> sqlite_compileoption_get|1
>> sqlite_compileoption_get|1
>> current_timestamp|1
>> current_timestamp|1
>> sqlite_compileoption_used|1
>> sqlite_compileoption_used|1

>Where's that pragma from Keith? Thanks, --DD

>There's no such pragma at https://sqlite.org/pragma.html
>and below you can see it's just as good as another, which pragma
>happily ignores.

They were added "experimentally" on July 7, 2017 -- meaning they do not show up 
in the documentation yet, and presumably that the implementation may change 
(and may currently be perhaps a little buggy or inconsistent -- if it breaks 
you own both halves when you use undocumented/pre-release features).  

You will note that for example the returned rows show both the builtin and 
user-defined function names, even though one may be overriding the other in 
various circumstances, and also no differentiation between scalar functions, 
aggregates, and no flags or argument numbers/types.  However if all you are 
looking for is whether or not a certain module or function is loaded (by name) 
on a connection then it returns that information.  Anything more specific is 
not returned though -- so you have to assume that the function you want is the 
one you see.

They appeared in the 3.20.0 release code although turned off by default -- you 
need to "build your own" with the preprocessor symbol 
SQLITE_INTROSPECTION_PRAGMAS defined.

The commit to trunk can be found here:

https://www.sqlite.org/src/info/e0b6ae92adfae46f

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.





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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-23 Thread Dominique Devienne
On Wed, Aug 23, 2017 at 6:11 PM, Keith Medcalf  wrote:

>
> sqlite> pragma function_list;
> group_concat|1
> group_concat|1
> julianday|1
> julianday|1
> nullif|1
> nullif|1
> sqlite_compileoption_get|1
> sqlite_compileoption_get|1
> current_timestamp|1
> current_timestamp|1
> sqlite_compileoption_used|1
> sqlite_compileoption_used|1
>

Where's that pragma from Keith? Thanks, --DD

There's no such pragma at https://sqlite.org/pragma.html
and below you can see it's just as good as another, which pragma happily
ignores.

I've requested at least twice on this list for this pragma to be added, so
of course you picked my interested.
Given all the other pragmas to introspect SQLite, I'm still baffled SQLite
doesn't have this one.

If it was a security concern, there are ways to mitigate it IMHO
(authorizer, register "hidden" functions, etc...).

C:\Users\ddevienne>sqlite3
SQLite version 3.10.2 2016-01-20 15:27:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> pragma function_list;
sqlite> pragma foobar;
sqlite>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-23 Thread curmudgeon
Thanks for the explanation Keith and the help. I've learned a lot the last
few days.



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97040.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-23 Thread Keith Medcalf

Excellent!

That format is because the program that gets them is written in Python and the 
"list" format is the native "tuple" output format of Python (for the returned 
row objects).  For example, if in the command line shell you issue this command:

SQLite version 3.21.0 2017-08-21 02:20:57
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select name as function_name, builtin from pragma_function_list() group 
by name collate nocase, builtin order by name collate nocase asc, builtin desc;
aavg|0
abs|1
acos|0
aggmd2|0
aggmd4|0
aggmd5|0
aggsha1|0
aggsha256|0
aggsha2_256|0

which is the table-valued function version of this:

sqlite> pragma function_list;
group_concat|1
group_concat|1
julianday|1
julianday|1
nullif|1
nullif|1
sqlite_compileoption_get|1
sqlite_compileoption_get|1
current_timestamp|1
current_timestamp|1
sqlite_compileoption_used|1
sqlite_compileoption_used|1



But in Python (with the standard dbapi module) if I execute something like (cn 
is the database connection object):

for row in cn.cursor().execute('select name as function_name, builtin from 
pragma_function_list() group by name collate nocase, builtin order by name 
collate nocase asc, builtin desc;'):
print('pragma_function_list() row=', row)

the printed output looks like this:

pragma_function_list() row= (u'aavg', 0)
pragma_function_list() row= (u'abs', 1)
pragma_function_list() row= (u'acos', 0)
pragma_function_list() row= (u'aggmd2', 0)
pragma_function_list() row= (u'aggmd4', 0)
pragma_function_list() row= (u'aggmd5', 0)
pragma_function_list() row= (u'aggsha1', 0)
pragma_function_list() row= (u'aggsha256', 0)
pragma_function_list() row= (u'aggsha2_256', 0)
pragma_function_list() row= (u'aggsha2_384', 0)
pragma_function_list() row= (u'aggsha2_512', 0)
pragma_function_list() row= (u'aggsha384', 0)
pragma_function_list() row= (u'aggsha3_224', 0)


The pragma's are documented on the SQLite3 documentation pages.
https://sqlite.org/pragma.html

pragma function_list;
pragma module_list;
pragma pragma_list;

are new in SQLite3 3.20.0 if you compile the amalgamation with 
SQLITE_INTROSPECTION_PRAGMAS defined.


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of curmudgeon
>Sent: Wednesday, 23 August, 2017 02:55
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Compiling spellfix for sqlite3
>
>Keith, I finally managed to use carray this morning. The C++ builder
>IDE had
>a facility for entering conditional defines in Project|Options. I had
>noticed this before asking the question on the c++ builder forum but
>hadn't
>realised the -D part of -DSQLITE_EXTRA_INIT=cor_init wasn't required.
>
>Thanks for all your help but would you mind if I haunted you just a
>little
>bit longer to clear something up?
>
>You sent me an email with SampleExts.zip and wrote
>
>When I build my sqlite3.dll (on windows with gcc) I get the following
>functions for every connection:
>
>collation_list row = (0, u'ROT13')
>collation_list row = (1, u'NUMERICS')
>...
>
>pragma_function_list() row= (u'aavg', 0)
>pragma_function_list() row= (u'abs', 1)
>pragma_function_list() row= (u'acos', 0)
>
>
>I don't recognise the above 'list' notation and could find nothing on
>it
>when googled. Could you point me to any documentation as I would like
>to add
>some functions/collations that would be automatically attached to
>every
>database connection.
>
>
>
>
>Keith Medcalf wrote
>> On Tuesday, 22 August, 2017 09:30, curmudgeon 
>
>> tam118118@
>
>>  wrote:
>>
>>>Your cast did the trick Keith and it compiled fine once I removed
>the
>>>'-DSQLITE_EXTRA_INIT=core_init' line but I have no idea how to get
>>>that directive into the c++ builder application. I've put up a
>question
>>>on the c++ builder forum but unanswered as yet.
>>
>> Yeah, it must be in there somewhere.  Can't help though as I have a
>deadly
>> allergy to IDE's.
>>
>> In a non-GUI you would specify it as a command line option to the
>compiler
>> (actually, to the pre-processor), as in:
>>
>> gcc -DSQLITE_EXTRA_INIT=core_init sqlite3.c
>>
>> ---
>> The fact that there's a Highway to Hell but only a Stairway to
>Heaven says
>> a lot about anticipated traffic volume.
>>
>>
>>
>>
>> ___
>> sqlite-users mailing list
>
>> sqlite-users@.sqlite
>
>> http://mailinglists.sqlite.org/cgi-bin/

Re: [sqlite] Compiling spellfix for sqlite3

2017-08-23 Thread curmudgeon
Keith, I finally managed to use carray this morning. The C++ builder IDE had
a facility for entering conditional defines in Project|Options. I had
noticed this before asking the question on the c++ builder forum but hadn't
realised the -D part of -DSQLITE_EXTRA_INIT=cor_init wasn't required.

Thanks for all your help but would you mind if I haunted you just a little
bit longer to clear something up?

You sent me an email with SampleExts.zip and wrote

When I build my sqlite3.dll (on windows with gcc) I get the following
functions for every connection:

collation_list row = (0, u'ROT13')
collation_list row = (1, u'NUMERICS')
...

pragma_function_list() row= (u'aavg', 0)
pragma_function_list() row= (u'abs', 1)
pragma_function_list() row= (u'acos', 0)


I don't recognise the above 'list' notation and could find nothing on it
when googled. Could you point me to any documentation as I would like to add
some functions/collations that would be automatically attached to every
database connection.




Keith Medcalf wrote
> On Tuesday, 22 August, 2017 09:30, curmudgeon 

> tam118118@

>  wrote:
> 
>>Your cast did the trick Keith and it compiled fine once I removed the
>>'-DSQLITE_EXTRA_INIT=core_init' line but I have no idea how to get
>>that directive into the c++ builder application. I've put up a question 
>>on the c++ builder forum but unanswered as yet.
> 
> Yeah, it must be in there somewhere.  Can't help though as I have a deadly
> allergy to IDE's.
> 
> In a non-GUI you would specify it as a command line option to the compiler
> (actually, to the pre-processor), as in:
> 
> gcc -DSQLITE_EXTRA_INIT=core_init sqlite3.c
> 
> ---
> The fact that there's a Highway to Hell but only a Stairway to Heaven says
> a lot about anticipated traffic volume.
> 
> 
> 
> 
> ___
> sqlite-users mailing list

> sqlite-users@.sqlite

> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users





--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97036.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-22 Thread Keith Medcalf

On Tuesday, 22 August, 2017 09:30, curmudgeon  wrote:

>Your cast did the trick Keith and it compiled fine once I removed the
>'-DSQLITE_EXTRA_INIT=core_init' line but I have no idea how to get
>that directive into the c++ builder application. I've put up a question 
>on the c++ builder forum but unanswered as yet.

Yeah, it must be in there somewhere.  Can't help though as I have a deadly 
allergy to IDE's.

In a non-GUI you would specify it as a command line option to the compiler 
(actually, to the pre-processor), as in:

gcc -DSQLITE_EXTRA_INIT=core_init sqlite3.c

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-22 Thread curmudgeon
Your cast did the trick Keith and it compiled fine once I removed the
'-DSQLITE_EXTRA_INIT=core_init' line but I have no idea how to get that
directive into the c++ builder application. I've put up a question on the
c++ builder forum but unanswered as yet.



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97028.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-21 Thread Keith Medcalf

On Monday, 21 August, 2017 11:44, curmudgeon wrote:

>Thanks Keith. I followed your instructions but I'm now getting the
>following compiler errors

>[bcc32 Error] carray.c(412): E2342 Type mismatch in parameter 'xInit'
>(wanted 'void (*)()', got 'void *')
>// on the 'nErr +=
>sqlite3_auto_extension((void*)sqlite3_carray_init); line'

This is because you are compiling with a C++ compiler and C++ is picky about 
types (or your compiler is too picky about types when processing C files).  In 
C, a void* can be used anywhere for anything -- it is a completely generic 
pointer -- and you are supposed to know what you are doing if you use one 
(since there is actually no such thing as a "void" that can be pointed at).

You need to change the cast to the expected type:

nErr += sqlite3_auto_extension((void(*)())sqlite3_carray_init);


>[bcc32 Error] carray.c(430): E2040 Declaration terminated incorrectly
>// on the '-DSQLITE_EXTRA_INIT=core_init' line

This is because these are compiler directives and do not go in the source code. 
 They are defines that you pass to the compiler as command line arguments.  IE, 
to have the equivalent of "#define SQLITE_EXTRA_INIT core_init" in effect 
before the sqlite3.c is compiled.  If your compiler has a hooey-gooey, then 
there is some place in it for you to create defines.  You need to define 
SQLITE_EXTRA_INIT=core_init.

>I assume carray.c wasn't being compiled at all the other way and
>that's why there were no errors reported. I tried wrapping the 
>carray.c code in extern "C" {...carray.c code...} in case it was 
>something to do with that but then I got a 'Declaration terminated 
>incorrectly' error on the first line which contains extern "C" {

Yeah.  Compiling C code in C++ mode is a dogs breakfast.  Actually, if 
sqlite3.c is being processed as C++ code I am surprised you are not getting 
billions of errors because many of the rules for incomplete types are different 
in C++ vs C.  When compiling C code the compiler you are using must be  
half-way C compliant and half-way C++ compliant ...





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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-21 Thread curmudgeon
Thanks Keith. I followed your instructions but I'm now getting the following
compiler errors

[bcc32 Error] carray.c(412): E2342 Type mismatch in parameter 'xInit'
(wanted 'void (*)()', got 'void *')
// on the 'nErr += sqlite3_auto_extension((void*)sqlite3_carray_init); line'

[bcc32 Error] carray.c(430): E2040 Declaration terminated incorrectly
// on the '-DSQLITE_EXTRA_INIT=core_init' line

I assume carray.c wasn't being compiled at all the other way and that's why
there were no errors reported. I tried wrapping the carray.c code in extern
"C" {...carray.c code...} in case it was something to do with that but then
I got a 'Declaration terminated incorrectly' error on the first line which
contains extern "C" {



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97006.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-21 Thread Keith Medcalf

You have to add the carray.c and core_init functions right at the end of the 
file (not inside any other code blocks).

The way you have it the carray.c is included only if SQLITE_ENABLE_STMTVTAB is 
enabled.

So it should look like this:

#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/** End of stmt.c
/

#include carray.c

>
>
>I then added the following code to the end of carray.c
>
>int core_init(const char* dummy)
>{
>   int nErr = 0;
>
>   nErr += sqlite3_auto_extension((void*)sqlite3_carray_init);
>
>   return nErr ? SQLITE_ERROR : SQLITE_OK;
>}
>

These are specified as defines to the compiler correct?  I don't think that the 
-DSQLITE_CORE is required because technically the amalgamation sqlite3.c 
defines it automatically ... I just specify it for the greater certainty.

-DSQLITE_CORE
-DSQLITE_EXTRA_INIT=core_init


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of curmudgeon
>Sent: Monday, 21 August, 2017 09:13
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Compiling spellfix for sqlite3
>
>Keith, I know this is an old post but it refers to something we
>discussed
>recently.
>
>I tried the following
>
>I added the #include carray.c line to just above the bottom of the
>amalgamation such that the last few lines are
>
>#include carray.c
>
>#endif /* SQLITE_CORE */
>#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
>
>/** End of stmt.c
>/
>
>
>
>I then added the following code to the end of carray.c
>
>int core_init(const char* dummy)
>{
>   int nErr = 0;
>
>   nErr += sqlite3_auto_extension((void*)sqlite3_carray_init);
>
>   return nErr ? SQLITE_ERROR : SQLITE_OK;
>}
>
>-DSQLITE_CORE
>-DSQLITE_EXTRA_INIT=core_init
>
>
>Everything compiled OK but when I tried to access carray in a query I
>got a
>"no such table" error. To be honest I had no idea where to put what
>and,
>through debugging, I know the core_init function was never entered.
>Can you
>tell me where I'm going wrong?
>
>
>
>
>--
>View this message in context:
>http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-
>tp70656p97003.html
>Sent from the SQLite mailing list archive at Nabble.com.
>___
>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


Re: [sqlite] Compiling spellfix for sqlite3

2017-08-21 Thread curmudgeon
Keith, I know this is an old post but it refers to something we discussed
recently.

I tried the following

I added the #include carray.c line to just above the bottom of the
amalgamation such that the last few lines are

#include carray.c

#endif /* SQLITE_CORE */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */

/** End of stmt.c
/



I then added the following code to the end of carray.c

int core_init(const char* dummy)
{
int nErr = 0;

nErr += sqlite3_auto_extension((void*)sqlite3_carray_init);

return nErr ? SQLITE_ERROR : SQLITE_OK;
}

-DSQLITE_CORE
-DSQLITE_EXTRA_INIT=core_init


Everything compiled OK but when I tried to access carray in a query I got a
"no such table" error. To be honest I had no idea where to put what and,
through debugging, I know the core_init function was never entered. Can you
tell me where I'm going wrong?




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-tp70656p97003.html
Sent from the SQLite mailing list archive at Nabble.com.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2013-08-25 Thread Richard Hipp
On Sun, Aug 25, 2013 at 6:25 AM, Mirat Bayrak wrote:

> I needed wanted to build "did you mean this?" feature to my website. I'm
> using sqlite3 and learned that i can use spellfix module to order tables
> via levenstein.
>
> I downloaded source code of
> sqlite3 and
> compiled spellfix.c (it's inside /ext/misc/) like this:
>
> gcc -shared -fPIC -Wall -I/tmp/sqlite-src-3071700/ spellfix.c -o spellfix
>
> It compiles successfuly but when i load it into sqlite:
>
> sqlite> .load ./spellfix
>
> I'm getting this error:
>
> Error: ./spellfix: undefined symbol: sqlite3_extension_init
>

You can specify the name of the entry point as a second argument:

.load ./spellfix sqlite3_spellfix_init

The error you are getting is because SQLite is trying to use the entry
point name "sqlite3_extension_init" which is not exported by the "spellfix"
module.

SQLite will normally guess the right entry point name, if you are using a
recent version of SQLite and you name your shared library
"libspellfix.so".  I'm not sure if it can guess the right name with the
shared library being called just "spellfix" or not.  I think I would
definitely want to add the ".so" suffix at least.  But it never hurts to
play it safe and specify the entry point name explicitly.


>
> I really have very few knowledge about compiling c programs. Did i do some
> mistake about compiling or something else is happened? What should i do?
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling spellfix for sqlite3

2013-08-25 Thread Keith Medcalf
> I downloaded source code of and compiled spellfix.c (it's inside /ext/misc/) 
> like this:
 
> gcc -shared -fPIC -Wall -I/tmp/sqlite-src-3071700/ spellfix.c -o spellfix

> It compiles successfuly but when i load it into sqlite:
 
> sqlite> .load ./spellfix
 
> I'm getting this error:
 
> Error: ./spellfix: undefined symbol: sqlite3_extension_init
 
> I really have very few knowledge about compiling c programs. Did i do
> some mistake about compiling or something else is happened? What should i do?

The init function name is sqlite3_spellfix_init

Current versions of sqlite3 should look for this name as well as the older 
generic name by default.  You can specify the entrypoint name on your .load 
command (or in the call to sqlite3_load_extension).

You can also simply append the spellfix.c (or any or all of the extensions) to 
the amalgamation code then add some code like this after that (all into the one 
amalgamation source file):

int core_init(const char* dummy)
{
int nErr = 0;

nErr += sqlite3_auto_extension((void*)sqlite3_ieee_init);
nErr += sqlite3_auto_extension((void*)sqlite3_nextchar_init);
nErr += sqlite3_auto_extension((void*)sqlite3_percentile_init);
nErr += sqlite3_auto_extension((void*)sqlite3_regexp_init);
nErr += sqlite3_auto_extension((void*)sqlite3_rot_init);

#ifndef SQLITE_OMIT_VIRTUALTABLE
nErr += sqlite3_auto_extension((void*)sqlite3_vtshim_init);
nErr += sqlite3_auto_extension((void*)sqlite3_amatch_init);
nErr += sqlite3_auto_extension((void*)sqlite3_closure_init);
nErr += sqlite3_auto_extension((void*)sqlite3_fuzzer_init);
nErr += sqlite3_auto_extension((void*)sqlite3_spellfix_init);
nErr += sqlite3_auto_extension((void*)sqlite3_wholenumber_init);
#endif

return nErr ? SQLITE_ERROR : SQLITE_OK;
}

Then add the following define when you compile the amalgamation to add the 
core_init function to the library initialization sequence.

-DSQLITE_EXTRA_INIT=core_init

So for example, you can append all the /ext/misc extensions to the end of the 
amalgamation, add the above code at the end after that, set the additional 
define when compiling, and your new sqlite3 engine will have all the extensions 
compiled in and available in every connection.




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


[sqlite] Compiling spellfix for sqlite3

2013-08-25 Thread Mirat Bayrak
I needed wanted to build "did you mean this?" feature to my website. I'm
using sqlite3 and learned that i can use spellfix module to order tables
via levenstein.

I downloaded source code of
sqlite3 and
compiled spellfix.c (it's inside /ext/misc/) like this:

gcc -shared -fPIC -Wall -I/tmp/sqlite-src-3071700/ spellfix.c -o spellfix

It compiles successfuly but when i load it into sqlite:

sqlite> .load ./spellfix

I'm getting this error:

Error: ./spellfix: undefined symbol: sqlite3_extension_init

I really have very few knowledge about compiling c programs. Did i do some
mistake about compiling or something else is happened? What should i do?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users