Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-20 Thread sanhua.zh
And which commands will check whether the schema is expired.
As far as I know, SELECT command will but PRAGMA table_info will not do this.


Original Message
Sender:Simon slavinslav...@bigfraud.org
Recipient:SQLite mailing listsqlite-us...@mailinglists.sqlite.org
Date:Monday, Aug 21, 2017 11:47
Subject:Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !


On 21 Aug 2017, at 3:22am, sanhua.zh sanhua...@foxmail.com wrote:  If so, who 
or which doc can tell me that which SQL will or will not update the schema ? 
Commands with CREATE, DROP, or ALTER update schema. Simon. 
___ 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] SQLite's Results Are Expired While Schema Is Changed !

2017-08-20 Thread Simon Slavin


On 21 Aug 2017, at 3:22am, sanhua.zh  wrote:

> If so, who or which doc can tell me that which SQL will or will not update 
> the schema ?

Commands with CREATE, DROP, or ALTER update schema.

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


Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !

2017-08-20 Thread sanhua.zh
Hello Jay, here is information update.


I find 2 new things.
1. This issue happens even two conns running in same thread.
2. And it is more important ! This issue only happens in WAL mode !


As I know, databases with journal mode use a file change counter to update 
schema while databases with WAL mode use wal-index to do this.
I'm using macOS with the system builtin sqlite framwork with 3.8.10.2. I think 
it should be a bug in wal-index.


Here is the very simple code to reproduce this problem.


```
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);


sqlite3* handle1;
rc = sqlite3_open(path, handle1);
assert(rc==0);
//  rc = sqlite3_exec(handle1, "PRAGMA journal_mode=WAL", NULL, NULL, NULL);
//  assert(rc==0);


sqlite3* handle2;
rc = sqlite3_open(path, handle2);
assert(rc==0);
//  rc = sqlite3_exec(handle2, "PRAGMA journal_mode=WAL", NULL, NULL, NULL);
//  assert(rc==0);


rc = sqlite3_exec(handle1, "CREATE TABLE test1 (i INTEGER)", NULL, NULL, NULL);
assert(rc==0);
//The sql below will return an error with 'no such table: test1' in WAL, but 
succeeds in journal mode.
rc = sqlite3_exec(handle2, "SELECT * FROM test1", NULL, NULL, NULL);
assert(rc==0);
```




Original Message
Sender:Jay kreibich...@kreibi.ch
Recipient:SQLite mailing listsqlite-us...@mailinglists.sqlite.org
Date:Friday, Aug 18, 2017 19:46
Subject:Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !


On Aug 18, 2017, at 4:04 AM, sanhua.zh sanhua...@foxmail.com wrote:  I am using 
SQLite in multi-thread mode, which means that different threads using different 
SQLite connection.  And now I find an issue that the results of SQLite C 
interface returned is expired while the schema of database is changed.The 
following sample runs in different threads, but I force them to 
runsequentially.Thread 1:  1. Conn A: Open, PRAGMA journal_mode=WAL  Thread 
2:  2.ConnB: Open, PRAGMA journal_mode=WAL  Thread 1:  3.ConnA: CREATE TABLE 
sample (i INTEGER);  Thread 2:  4.ConnB: PRAGMA table_info('sample')
Firstly, both thread 1 and 2 do initialization for their own conn, which is to 
read to schema into memory.  Then, Conn A creates a table with Conn A.  
Finally, `PRAGMA table_info(sample)` is called in thread 2 with Conn B and it 
returns nothing.  The same thing could happen if I change the step 4 to 
`sqlite3_table_column_metadata` or some other interfaces.I do know the 
reason should be the expired in-memory-schema. But I find no docs about which 
interface will or will not update the schema and what should I do while I call 
a non-update-schema interface ? See the bottom of the sqlite3_prepare*() docs: 
https://www.sqlite.org/c3ref/prepare.html And the SQLITE_SCHEMA docs: 
https://www.sqlite.org/rescode.html#schema As the docs say, make sure you’re 
using sqlite3_prepare*_v2() or _v3(). If a statement is prepared with these 
newer versions, it will handle most expiration situations automatically by 
re-preparing the statement. Generally speaking, if you do get an SQLITE_SCHEMA 
error, you need to rollback the current transaction, re-prepare the statements, 
and try again. -j -- Jay A. Kreibich  J A Y @ K R E I B I.C H  "Intelligence is 
like underwear: it is important that you have it, but showing it to the wrong 
people has the tendency to make them feel uncomfortable." -- Angela Johnson 
___ 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] SQLite's Results Are Expired While Schema Is Changed !

2017-08-20 Thread sanhua.zh
Firstly, I use `PRAGMA table_info('sample')` in my sample case, which means 
that it also calls `sqlite3_prepare_v2` but do not re-prepare. Maybe it does 
not contain the specific OP checking the schema.


Secondly, it's hard to know when the schema is changed in multi-conns 
implementation. So as telling them to re-prepare.


So, As your word "comthis situation would be a problem" said, is it that I 
should not use the non-update-schema-operation in multi-conns implementation ?
If so, who or which doc can tell me that which SQL will or will not update the 
schema ?


Original Message
Sender:Jay kreibich...@kreibi.ch
Recipient:SQLite mailing listsqlite-us...@mailinglists.sqlite.org
Date:Friday, Aug 18, 2017 19:46
Subject:Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !


On Aug 18, 2017, at 4:04 AM, sanhua.zh sanhua...@foxmail.com wrote:  I am using 
SQLite in multi-thread mode, which means that different threads using different 
SQLite connection.  And now I find an issue that the results of SQLite C 
interface returned is expired while the schema of database is changed.The 
following sample runs in different threads, but I force them to 
runsequentially.Thread 1:  1. Conn A: Open, PRAGMA journal_mode=WAL  Thread 
2:  2.ConnB: Open, PRAGMA journal_mode=WAL  Thread 1:  3.ConnA: CREATE TABLE 
sample (i INTEGER);  Thread 2:  4.ConnB: PRAGMA table_info('sample')
Firstly, both thread 1 and 2 do initialization for their own conn, which is to 
read to schema into memory.  Then, Conn A creates a table with Conn A.  
Finally, `PRAGMA table_info(sample)` is called in thread 2 with Conn B and it 
returns nothing.  The same thing could happen if I change the step 4 to 
`sqlite3_table_column_metadata` or some other interfaces.I do know the 
reason should be the expired in-memory-schema. But I find no docs about which 
interface will or will not update the schema and what should I do while I call 
a non-update-schema interface ? See the bottom of the sqlite3_prepare*() docs: 
https://www.sqlite.org/c3ref/prepare.html And the SQLITE_SCHEMA docs: 
https://www.sqlite.org/rescode.html#schema As the docs say, make sure you’re 
using sqlite3_prepare*_v2() or _v3(). If a statement is prepared with these 
newer versions, it will handle most expiration situations automatically by 
re-preparing the statement. Generally speaking, if you do get an SQLITE_SCHEMA 
error, you need to rollback the current transaction, re-prepare the statements, 
and try again. -j -- Jay A. Kreibich  J A Y @ K R E I B I.C H  "Intelligence is 
like underwear: it is important that you have it, but showing it to the wrong 
people has the tendency to make them feel uncomfortable." -- Angela Johnson 
___ 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] typo in documentation

2017-08-20 Thread Richard Hipp
Should be fixed now.  Thanks.

On 8/20/17, Dennis Cote  wrote:
> On the web page at http://sqlite.org/csv.html the following text appears:
>
>  The CVS virtual table is not built into the SQLite amalgamation.
>
> The acronym CVS should be CSV.
>
> HTH
>
> Dennis Cote
>
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


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


Re: [sqlite] dqlite - SQLite replication and failover library

2017-08-20 Thread Free Ekanayaka
Wout Mertens  writes:

> Oh I see, of course. So I assume the client library automatically sends
> write commands to the current leader?

No, that's up the application for now, the library just returns you an
error if you attempt a write on a non-leader node.

> I wonder if there is value in setting a preferred leader, but probably
> that's messing too much with the Raft protocol.

I'm not entirely sure to understand, but if you mean "if possible, I
generally would like the leader to be this node, please", no that's
currently not supported. I don't see a reason why it couldn't be added,
but it seems a kind of exotic requirement in today's "cats vs pets" way
of thinking to nodes.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] dqlite - SQLite replication and failover library

2017-08-20 Thread Wout Mertens
Oh I see, of course. So I assume the client library automatically sends
write commands to the current leader?

I wonder if there is value in setting a preferred leader, but probably
that's messing too much with the Raft protocol.

On Sun, Aug 20, 2017, 11:44 PM Free Ekanayaka  wrote:

> Wout Mertens  writes:
>
> > Very interesting!
> >
> > So how does it behave during conflict situations? Raft selects a winning
> > WAL write and any others in flight are aborted?
>
> Ah yeah this is probably something that was not clear from the docs or
> from my presentation.
>
> There can't be a conflict situation. Raft's model is that only the
> leader can append new log entries, which translated to dqlite means that
> only the leader can write new WAL frames. So this means that any attempt
> to perform a write transaction on a non-leader node will fail with a
> SQLITE_NOT_LEADER error (and in this case clients are supposed to retry
> against whoever is the new leader).
>
> I'm going to add this to the FAQ.
>
> > And when not enough nodes are available, writes are hung until
> > consensus?
>
> Yes, but there's a (configurable timeout). It's not possible to *not*
> have timeout (although you can set it really really high of course :)
>
> > I won't be able to use it due to Go but it's great to know that this is
> on
> > the horizon of possibilities… Very nice!
>
> Yeah I think Go is somehow limiting, but hopefully once Raft libraries
> mature in C/Raft, dqlite can act as reference/prototype.
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] dqlite - SQLite replication and failover library

2017-08-20 Thread Free Ekanayaka
Free Ekanayaka  writes:

>> And when not enough nodes are available, writes are hung until
>> consensus?
>
> Yes, but there's a (configurable timeout).

BTW, this is a consequence of Raft sitting in the CP spectrum of the CAP
theorem: in case of a network partition it chooses consistency and
sacrifices availability.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] dqlite - SQLite replication and failover library

2017-08-20 Thread Free Ekanayaka
Wout Mertens  writes:

> Very interesting!
>
> So how does it behave during conflict situations? Raft selects a winning
> WAL write and any others in flight are aborted?

Ah yeah this is probably something that was not clear from the docs or
from my presentation.

There can't be a conflict situation. Raft's model is that only the
leader can append new log entries, which translated to dqlite means that
only the leader can write new WAL frames. So this means that any attempt
to perform a write transaction on a non-leader node will fail with a
SQLITE_NOT_LEADER error (and in this case clients are supposed to retry
against whoever is the new leader).

I'm going to add this to the FAQ.

> And when not enough nodes are available, writes are hung until
> consensus?

Yes, but there's a (configurable timeout). It's not possible to *not*
have timeout (although you can set it really really high of course :)

> I won't be able to use it due to Go but it's great to know that this is on
> the horizon of possibilities… Very nice!

Yeah I think Go is somehow limiting, but hopefully once Raft libraries
mature in C/Raft, dqlite can act as reference/prototype.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] dqlite - SQLite replication and failover library

2017-08-20 Thread Wout Mertens
Very interesting!

So how does it behave during conflict situations? Raft selects a winning
WAL write and any others in flight are aborted?

And when not enough nodes are available, writes are hung until consensus?

I won't be able to use it due to Go but it's great to know that this is on
the horizon of possibilities… Very nice!

On Sat, Aug 19, 2017 at 10:47 AM Free Ekanayaka  wrote:

> Hi,
>
> first of all let me thank Richard Hipp and the rest of the SQLite team
> and community for such a great piece of software. I've been recently
> working with SQLite's code base and found it an absolute pleasure to
> read (and have learned from it too).
>
> In this mail I'd like to:
>
> 1) Present dqlite, a library replicating your application's SQLite
>database across N nodes and safely surviving any minority of them
>dying or disconnecting (only for Go applications for now, see below).
>
> 2) Submit a patch to SQLite that introduces a minimal replication API,
>and get feedback about its possible inclusion upstream.
>
> = dqlite =
>
> It's a Go package that uses the Raft algorithm to replicate SQLite WAL
> frames across a cluster of nodes. This roughly means that you can open a
> SQLite connection using the "database/sql" standard lib API and have
> anything you transactionally replicated. No external process needed.
>
> Ideally this library should have been written in C or Rust, to support
> binding to any language. However, due to the use case and timeline of
> the first project that will use it (LXD [0]), and due to the lack of
> mature Raft implementations in C/Rust, Go was chosen instead. It should
> hopefully at least serve as reference to anyone needing a C/Rust
> version.
>
> The work has been funded by Canonical, the company behind Ubuntu. Please
> see the dqlite's home page [1] for more details.
>
> = SQLite replication API patch =
>
> This is the SQLite patch that dqlite depends on. It essentially adds a
> few key hooks in the pager and write-ahead log to let external libraries
> like dqlite implement WAL-based database replication.
>
> As you'll quickly see, it's by no means ready for upstream inclusion, in
> particular it lacks unit tests and more comprehensive documentation
> comments (note however that virtually every code path introduced by the
> patch is already exercised indirectly by dqlite's own unit tests).
>
> If the SQLite team thinks there is room for upstream inclusion, I'll be
> more than glad to do the necessary work to make the patch adhere to
> SQLite's standards and go through a review process.
>
> The patch has currently 703 additions and 22 deletions, and is published
> on GitHub [2].
>
> Cheers,
>
> Free
>
> [0] https://linuxcontainers.org/
> [1] https://github.com/CanonicalLtd/dqlite
> [2]
> https://github.com/CanonicalLtd/sqlite/commit/2a9aa8b056f37ae05f38835182a2856ffc95aee4
> ___
> 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] Enforcing uniqueness from multiple indexes

2017-08-20 Thread Wout Mertens
Oh wow, I didn't know about ON CONFLICT, thanks!

Unfortunately the behavior on UPDATE (actually INSERT OR REPLACE in my
case) is not the desired behavior, it removes the row with the same k but
different id.

However, using a TRIGGER BEFORE INSERT as well as UPDATE, as proposed by
Richard, does the trick.

I tried a mix of both too but the triggers were easier to understand for me.

On Fri, Aug 18, 2017 at 7:08 PM David Raymond 
wrote:

> Tried it and found a  issue with update, though it might
> actually work the way he wants. Good call though, I keep forgetting the on
> conflict thing can be on table creation and not just for a query.
>
> --continuing from your script...
>
> sqlite> select * from demo;
> --EQP-- 0,0,0,SCAN TABLE demo
> id|k|otherstuff
> 1|10|One-Mississippi
> 2|40|Four-Mississippi
> 3|30|Three-Mississippi
>
> sqlite> update demo set id = 1 where k = 30;
> --EQP-- 0,0,0,SEARCH TABLE demo USING INDEX sqlite_autoindex_demo_1 (k=?)
>
> sqlite> select * from demo;
> --EQP-- 0,0,0,SCAN TABLE demo
> id|k|otherstuff
> 1|30|Three-Mississippi
> 2|40|Four-Mississippi
>
> sqlite> update demo set k = 40 where id = 1;
> --EQP-- 0,0,0,SEARCH TABLE demo USING INTEGER PRIMARY KEY (rowid=?)
> Error: UNIQUE constraint failed: demo.k
>
> sqlite> update demo set id = 1, k = 30 where id = 2;
> --EQP-- 0,0,0,SEARCH TABLE demo USING INTEGER PRIMARY KEY (rowid=?)
>
> sqlite> select * from demo;
> --EQP-- 0,0,0,SCAN TABLE demo
> id|k|otherstuff
> 1|30|Four-Mississippi
>
> sqlite>
>
> -Original Message-
> From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org]
> On Behalf Of R Smith
> Sent: Friday, August 18, 2017 12:18 PM
> To: sqlite-users@mailinglists.sqlite.org
> Subject: Re: [sqlite] Enforcing uniqueness from multiple indexes
>
>
>
> On 2017/08/18 6:08 PM, R Smith wrote:
> >
> > Isn't this what conflict clauses on constraints are for?
> >
>
> Apologies, I usually add the test-case scripts in case anyone else wish
> to test it or similar, the case in question herewith added below:
>
>-- SQLite version 3.17.0  [ Release: 2017-02-13 ]  on SQLitespeed
> version 2.0.2.4.
>-- Script Items: 7  Parameter Count: 0
>--
>
> 
>
> CREATE TABLE demo(
>id INTEGER PRIMARY KEY ON CONFLICT REPLACE,
>k TEXT UNIQUE ON CONFLICT ABORT,
>otherstuff ANY
> );
>
> INSERT INTO demo VALUES
> (1,10,'One-Mississippi'),
> (2,20,'Two-Mississippi'),
> (3,30,'Three-Mississippi')
> ;
>
>-- This one works as expected, replacing the previous key.
> INSERT INTO demo VALUES (2,40,'Four-Mississippi');
>
> SELECT * FROM demo;
>--  id  |  k  | otherstuff
>--  | --- | -
>--   1  |  10 | One-Mississippi
>--   2  |  40 | Four-Mississippi
>--   3  |  30 | Three-Mississippi
>
>-- This one should fail since the id is new but k conflicts...
> INSERT INTO demo VALUES (5,40,'Four-Mississippi-Again');
>-- and does:
>
>-- 2017-08-18 18:14:20.463  |  [ERROR]  UNIQUE constraint failed:
> demo.k
>--   Script Stats: Total Script Execution Time: 0d 00h 00m and
> 00.025s
>-- Total Script Query Time: 0d 00h 00m and
> 00.004s
>-- Total Database Rows Changed: 4
>-- Total Virtual-Machine Steps: 167
>-- Last executed Item Index:5
>-- Last Script Error: Script Failed in Item 4: UNIQUE
> constraint failed: demo.k
>--
>
> 
>
>-- 2017-08-18 18:14:20.465  |  [Info]   Script failed - Rolling
> back...
>-- 2017-08-18 18:14:20.466  |  [Success]Transaction Rolled back.
>-- 2017-08-18 18:14:20.466  |  [ERROR]  Failed to complete:
> Script Failed in Item 4: UNIQUE constraint failed: demo.k
>--
>
> 
>
> ___
> 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
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] typo in documentation

2017-08-20 Thread Dennis Cote

On the web page at http://sqlite.org/csv.html the following text appears:

    The CVS virtual table is not built into the SQLite amalgamation.

The acronym CVS should be CSV.

HTH

Dennis Cote

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


Re: [sqlite] Why the high cost of a double sort

2017-08-20 Thread Clemens Ladisch
Simon Slavin wrote:
> On 19 Aug 2017, at 10:48pm, Cecil Westerhof wrote:
>> I was also told that you never should put a sort on a view. Is that true,
>> or a bit to strong?
>
> Generally, you put the ORDER BY on the SELECT you’re using the consult
> the VIEW.  Technically speaking a VIEW is just a set of records and the
> ORDER BY should be a last-minute thing just before presentation of the
> results.

The SQL standard and  say:
| If a SELECT statement that returns more than one row does not have an
| ORDER BY clause, the order in which the rows are returned is undefined.

ORDER BY clauses in any subqueries/views/CTEs are not guaranteed to keep
the order in the outermost query.  It's possible for the database to
optimize the query by using some index or cache, and that can result in
a different order.

> But it can be useful for someone submitting commands manually to create
> a VIEW with ORDER BY.  For instance, using the command-line shell to
> investigate weird results, or for those cases where you’re using SQLite
> like a spreadsheet to arrive at a one-off result.  So I think an outright
> ban is a little strong.

In practice, when the outer query is implemented by simply scanning over
the inner query's rows, the order will not change.  But there is no
guarantee that the implementation will always stay the same.


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


Re: [sqlite] Including sqlite3ext.h instead of sqlite3.h

2017-08-20 Thread x
Having read the link Dan suggested I take it I shouldn’t be changing all my 
sqlite3.h includes to sqlite3ext.h. I should only be using sqlite3ext.h in the 
file I’m creating for the loadable extension? I’m very short on experience and 
easily confused when it comes to compiler directives, dll’s, filing etc.

To start off, I’m looking to use the carray extension. Keith has made some 
suggestions to me regarding adding code to the bottom of the amalgamation file 
but for the time being I’m trying to follow some of the sqlite documentation. 
On this page https://www.sqlite.org/carray.html it says

The carray() function is not compiled into SQLite by default. It is available 
as a loadable extension in the 
ext/misc/carray.c
 source file.

When I click on the ext/mis/carray.c link it takes me to a page with source 
code. Am I supposed to copy and paste that source code or is it already in the 
amalgamation somewhere? Or is there some files beyond the amalgamation I should 
be downloading?

Tom


From: Dan Kennedy
Sent: 20 August 2017 09:21
To: 
sqlite-users@mailinglists.sqlite.org
Subject: Re: [sqlite] Including sqlite3ext.h instead of sqlite3.h

On 08/20/2017 02:33 PM, x wrote:
> This morning I tried creating a new blank package on c++ builder and then 
> added
>
> #include “sqlite3ext.h”
>
> Same error message : E245 Undefined symbol ‘sqlite3_api’.
>
> Is there some define I should have set?

Add "SQLITE_EXTENSION_INIT1" on a line by itself after including
sqlite3ext.h:

   http://sqlite.org/loadext.html#programming_loadable_extensions

Dan.



>
> Full code
>
>
> //---
> #include "sqlite3ext.h"
> #include 
> #pragma hdrstop
> #pragma package(smart_init)
> //---
>
> //   Package source.
> //---
>
>
> #pragma argsused
> extern "C" int _libmain(unsigned long reason)
> {
>  sqlite3 *DB;
>  sqlite3_stmt *s;
>  sqlite3_open("c:/SQLiteData/Meta.db",&DB); // error line
>  sqlite3_close(DB);
>  return 1;
> }
> //---
> ___
> 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

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


Re: [sqlite] Including sqlite3ext.h instead of sqlite3.h

2017-08-20 Thread x
Thanks Dan. It now compiles but gives me warnings about ‘sqlite3_api’ being 
defined in more than one module. ‘sqlite3ext.h’ is included in several files 
although I only added the SQLITE_EXTENSION_INIT1 line to one such file.


> This morning I tried creating a new blank package on c++ builder and then 
> added
>
> #include “sqlite3ext.h”
>
> Same error message : E245 Undefined symbol ‘sqlite3_api’.
>
> Is there some define I should have set?

Add "SQLITE_EXTENSION_INIT1" on a line by itself after including
sqlite3ext.h:

   http://sqlite.org/loadext.html#programming_loadable_extensions

Dan.



>
> Full code
>
>
> //---
> #include "sqlite3ext.h"
> #include 
> #pragma hdrstop
> #pragma package(smart_init)
> //---
>
> //   Package source.
> //---
>
>
> #pragma argsused
> extern "C" int _libmain(unsigned long reason)
> {
>  sqlite3 *DB;
>  sqlite3_stmt *s;
>  sqlite3_open("c:/SQLiteData/Meta.db",&DB); // error line
>  sqlite3_close(DB);
>  return 1;
> }
> //---
> ___
> 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] Including sqlite3ext.h instead of sqlite3.h

2017-08-20 Thread Dan Kennedy

On 08/20/2017 02:33 PM, x wrote:

This morning I tried creating a new blank package on c++ builder and then added

#include “sqlite3ext.h”

Same error message : E245 Undefined symbol ‘sqlite3_api’.

Is there some define I should have set?


Add "SQLITE_EXTENSION_INIT1" on a line by itself after including 
sqlite3ext.h:


  http://sqlite.org/loadext.html#programming_loadable_extensions

Dan.





Full code


//---
#include "sqlite3ext.h"
#include 
#pragma hdrstop
#pragma package(smart_init)
//---

//   Package source.
//---


#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
 sqlite3 *DB;
 sqlite3_stmt *s;
 sqlite3_open("c:/SQLiteData/Meta.db",&DB); // error line
 sqlite3_close(DB);
 return 1;
}
//---
___
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] Including sqlite3ext.h instead of sqlite3.h

2017-08-20 Thread x
This morning I tried creating a new blank package on c++ builder and then added

#include “sqlite3ext.h”

Same error message : E245 Undefined symbol ‘sqlite3_api’.

Is there some define I should have set?

Full code


//---
#include "sqlite3ext.h"
#include 
#pragma hdrstop
#pragma package(smart_init)
//---

//   Package source.
//---


#pragma argsused
extern "C" int _libmain(unsigned long reason)
{
sqlite3 *DB;
sqlite3_stmt *s;
sqlite3_open("c:/SQLiteData/Meta.db",&DB); // error line
sqlite3_close(DB);
return 1;
}
//---
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users