Re: [sqlite] sequencer

2017-08-03 Thread petern
Sylvain, are you happy with the performance? Maybe you are using it differently but, from my tests, the DEFAULT clause is ignored for PRIMARY KEY columns. I had to use an ordinary column with UNIQUE constraint to test your extension. Below is a tester for 1 million rows which completes in

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Gwendal Roué
But... why don't you simply ask your users for a static string as well??? C++ makes it trivial to support this requirement of the C API. // pointerType should be a static string void wxSQLite3Statement::Bind(int paramIndex, void* pointer, char *pointerType,

Re: [sqlite] sequencer

2017-08-03 Thread Sylvain Pointeau
Le ven. 4 août 2017 à 02:42, Nico Williams a écrit : > On Fri, Aug 04, 2017 at 12:35:56AM +0200, Sylvain Pointeau wrote: > > void sp_seq_init(sqlite3_context *context, int argc, sqlite3_value > **argv) { > > int rc = 0; > > sqlite3_stmt *stmt; > > sqlite3 *db =

Re: [sqlite] sequencer

2017-08-03 Thread Nico Williams
On Thu, Aug 03, 2017 at 07:42:12PM -0500, Nico Williams wrote: > On Fri, Aug 04, 2017 at 12:35:56AM +0200, Sylvain Pointeau wrote: > I think some type checking should be done. > > You could just take the argv[] values and bind them directly to the > insert below, and use CHECK constraints on the

Re: [sqlite] Feature request: check for 'lib' prefix for load_extension()

2017-08-03 Thread Nico Williams
On Tue, Aug 01, 2017 at 10:56:47AM -0700, Matt Chambers wrote: > load_extension() has the very sensible behavior of: > > So for example, if "samplelib" cannot be loaded, then names like > > "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might be tried > > also. > > I would like to see

Re: [sqlite] sequencer

2017-08-03 Thread Nico Williams
On Fri, Aug 04, 2017 at 12:35:56AM +0200, Sylvain Pointeau wrote: > void sp_seq_init(sqlite3_context *context, int argc, sqlite3_value **argv) { > int rc = 0; > sqlite3_stmt *stmt; > sqlite3 *db = sqlite3_context_db_handle(context); If you use sqlite3_create_function*() with nArg == -1 then

Re: [sqlite] sequencer

2017-08-03 Thread petern
Neat. For production, you might want to check the type on function arguments before using them. Is it working fairly fast on inserts? That is, I presume, if this is intended for bypassing restrictions on the DEFAULT clause (expr) of column-constraint in a CREATE TABLE statement:

Re: [sqlite] Feature request: check for 'lib' prefix for load_extension()

2017-08-03 Thread J Decker
On Thu, Aug 3, 2017 at 10:42 AM, Bob Friesenhahn < bfrie...@simple.dallas.tx.us> wrote: > On Tue, 1 Aug 2017, Matt Chambers wrote: > > load_extension() has the very sensible behavior of: >> >>> So for example, if "samplelib" cannot be loaded, then names like >>> "samplelib.so" or

Re: [sqlite] sequencer

2017-08-03 Thread Sylvain Pointeau
Hello, please find below my implementation of a sequence, I am open for any critic! Best regards, Sylvain --- #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 void sp_seq_init(sqlite3_context *context, int argc, sqlite3_value

[sqlite] Checkin d8637bad produces bad amalgamation

2017-08-03 Thread Keith Medcalf
Check-in d8637bad produces a bad amalgamation output. Index: tool/mksqlite3c-noext.tcl == --- tool/mksqlite3c-noext.tcl +++ tool/mksqlite3c-noext.tcl @@ -26,11 +26,11 @@ # from in this file. The version number is needed to

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Nico Williams
On Thu, Aug 03, 2017 at 08:33:31PM +0200, Ulrich Telle wrote: > > Rhetorical: Why not use the pointer value itself then instead of the > > contents of the string? After all, the string should just be a .text > > section constant string... > > The SQLite developer team chose a string

Re: [sqlite] command shell .timeout

2017-08-03 Thread Roman Fleysher
Thank you, Richard. Roman From: sqlite-users [sqlite-users-boun...@mailinglists.sqlite.org] on behalf of Richard Hipp [d...@sqlite.org] Sent: Thursday, August 03, 2017 3:38 PM To: SQLite mailing list Subject: Re: [sqlite] command shell .timeout On

Re: [sqlite] command shell .timeout

2017-08-03 Thread Richard Hipp
On 8/3/17, Roman Fleysher wrote: > Dear SQLiters, > > I am using sqlit3 command shell. It has ".timeout" command. What is the > difference between: > > .timeout MS > PRAGMA busy_timeout = milliseconds; They accomplish the same thing. The ".timeout" command (which

[sqlite] command shell .timeout

2017-08-03 Thread Roman Fleysher
Dear SQLiters, I am using sqlit3 command shell. It has ".timeout" command. What is the difference between: .timeout MS PRAGMA busy_timeout = milliseconds; I am getting "database is locked" when accessing the same file from multiple concurrent shells and trying to set timeouts to avoid this.

Re: [sqlite] Bug: Nested function call to replace() throws parser stack overflow exception

2017-08-03 Thread Brian Clifford
Thanks for looking into this, I see in the original example I passed in a nested call of 28 replaces() this was the cutoff point where it would fail, the following line has about 36 replaces() this fails for me: replace(replace(replace(replace(replace(replace(replace(replace(replace(

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Nico, > Rhetorical: Why not use the pointer value itself then instead of the > contents of the string? After all, the string should just be a .text > section constant string... The SQLite developer team chose a string representation for the pointer type to make naming collisions less likely.

Re: [sqlite] Feature request: check for 'lib' prefix for load_extension()

2017-08-03 Thread Bob Friesenhahn
On Tue, 1 Aug 2017, Matt Chambers wrote: load_extension() has the very sensible behavior of: So for example, if "samplelib" cannot be loaded, then names like "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might be tried also. I would like to see that extended to include

Re: [sqlite] sequencer

2017-08-03 Thread Nico Williams
On Thu, Aug 03, 2017 at 06:59:44PM +0300, Alek Paunov wrote: > On 2017-08-02 20:24, Nico Williams wrote: > >I've implemented "inheritance" with triggers to map DMLs on "derived" > >tables onto "base" tables. That works and is much more general. If you > >need a rowid, however, the triggers have

Re: [sqlite] sequencer

2017-08-03 Thread Alek Paunov
On 2017-08-02 20:24, Nico Williams wrote: On Wed, Aug 02, 2017 at 07:48:52PM +0300, Alek Paunov wrote: On 2017-08-02 18:23, Sylvain Pointeau wrote: ... CREATE SEQUENCE IF NOT EXISTS SEQ_1 START WITH 12123; insert into MYTABLE(SPECIFIED_NUMBER, OTHERINFO) values (seq_1.nextval, 'other info')

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Nico Williams
On Thu, Aug 03, 2017 at 12:33:05PM +0300, Paul wrote: > To me it seems like that string is very tightly coupled with the > actual pointer being bound. I think it's a good idea, in case you > cannot make it a literal or static, to keep it with an object whose > pointer you bind. Rhetorical: Why

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Richard, > Can you please provide more details on how having a dynamic string for > the pointer type would be helpful? What is it that you are trying to > do that string constant will not work? Please be as specific as > possible, so that I might better understand your problem. I maintain a

Re: [sqlite] sequencer

2017-08-03 Thread Nico Williams
On Thu, Aug 03, 2017 at 12:25:00PM +0200, Sylvain Pointeau wrote: > On Thu, 3 Aug 2017 at 08:04, Hick Gunter wrote: > > A sequence is very easily implemented as a virtual table that keeps the > > current values in a separate table my_sequences (name text primary key, > > initial

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Richard, > On 8/3/17, Ulrich Telle wrote: > > > > The description of the new pointer-passing interface gives the impression > > that restricting the pointer type parameter to static strings or literals > > prevents misuse of the new feature. And that is definitely not the

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Peter, > On 8/3/17, 9:16 AM, "sqlite-users on behalf of Ulrich Telle"wrote: > > The description of the new pointer-passing interface gives the > > impression that restricting the pointer type parameter to static > > strings or literals prevents misuse of the new feature. > > The term I used was

Re: [sqlite] Bug: Nested function call to replace() throws parser stack overflow exception

2017-08-03 Thread Simon Slavin
On 3 Aug 2017, at 3:33pm, petern wrote: > The deeply nested string replace pattern comes up frequently. A > suggestion. Why not a built in aggregate replace function? Two more suggestions: Create a function which does exactly what you want. Call it

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Richard Hipp
On 8/3/17, Ulrich Telle wrote: > > Right. And therefore I think that the restriction to static strings or > literals for the pointer type parameter just makes life a bit harder for > honest developers of wrappers or the like, but prevents nothing. > Can you please provide

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Richard Hipp
On 8/3/17, Ulrich Telle wrote: > > The description of the new pointer-passing interface gives the impression > that restricting the pointer type parameter to static strings or literals > prevents misuse of the new feature. And that is definitely not the case. It > might be a

Re: [sqlite] Bug: Nested function call to replace() throws parser stack overflow exception

2017-08-03 Thread petern
The deeply nested string replace pattern comes up frequently. A suggestion. Why not a built in aggregate replace function? As such, the example here would be more readable and not limited by stack depth as the expression: SELECT replace(Transcript,column1,column2) FROM (VALUES

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Peter Da Silva
On 8/3/17, 9:16 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > The description of the new pointer-passing interface gives the impression > that restricting the pointer type parameter to static strings or

Re: [sqlite] Cut off paragraph in pointer documentation

2017-08-03 Thread Richard Hipp
On 8/3/17, J. King wrote: > The fifth paragraph of > ends after two > words, "Note that". > Thank you. Should be fixed now. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Peter, > On 8/3/17, 8:56 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > > Nevertheless, I think the pointer type string restriction gives a false > > sense of security. > > You described creating a malicious extension that would give you the ability > to probe pointers by forging

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Peter Da Silva
On 8/3/17, 8:56 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > Nevertheless, I think the pointer type string restriction gives a false sense > of security. You described creating a malicious extension that

[sqlite] Cut off paragraph in pointer documentation

2017-08-03 Thread J. King
The fifth paragraph of ends after two words, "Note that". -- J. King ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Peter, > On 8/3/17, 8:27 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > > I really don't think that the latter is true. To overcome the restriction > > is extremly simple, if you don't care about memory leaks. Just do [...] > > If you’re creating a malicious extension, sure. But if you’re

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Richard, > As the desire for dynamic pointer type strings seems to be a recurring > theme, I have added lots of extra documentation that attempts to > explain why the pointer-passing interfaces deliberately use a constant > static string for the pointer type: > >

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Gwendal Roué
> Le 3 août 2017 à 15:27, Ulrich Telle a écrit : > > Thanks for the pointer. I have to admit that I referred to > http://sqlite.org/c3ref/bind_blob.html > . No offense :-) The SQLite documentation has organically grown, and

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Peter Da Silva
On 8/3/17, 8:27 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > I really don't think that the latter is true. To overcome the restriction is > extremly simple, if you don't care about memory leaks. Just do

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Gwendal, > > Le 3 août 2017 à 14:27, Peter Da Silva a > > écrit : > > > > On 8/3/17, 4:22 AM, "sqlite-users on behalf of Ulrich Telle" > > > ulrich.te...@gmx.de> wrote: > >> IMHO it would be better if

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Richard Hipp
As the desire for dynamic pointer type strings seems to be a recurring theme, I have added lots of extra documentation that attempts to explain why the pointer-passing interfaces deliberately use a constant static string for the pointer type: https://sqlite.org/bindptr.html#ptrtyp -- D.

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Peter, > On 8/3/17, 4:22 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > > IMHO it would be better if the function sqlite3_bind_pointer would make a > > copy of the type string > > and would thus be independent of the life span of the type parameter. > > I believe that this was a

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Gwendal Roué
> Le 3 août 2017 à 14:27, Peter Da Silva a > écrit : > > On 8/3/17, 4:22 AM, "sqlite-users on behalf of Ulrich Telle" > ulrich.te...@gmx.de> wrote: >> IMHO it would be better if the function

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Peter Da Silva
On 8/3/17, 4:22 AM, "sqlite-users on behalf of Ulrich Telle" wrote: > IMHO it would be better if the function sqlite3_bind_pointer would make a > copy of the type string and would thus be independent of the life

Re: [sqlite] Bug: Nested function call to replace() throws parser stack overflow exception

2017-08-03 Thread Richard Hipp
I am unable to reproduce the problem. Do you have any additional hints on how to make this fail? The depth of the stack in the push-down automaton used by the parser is deliberately limited to 100 levels. This is a feature, not a bug. See https://www.sqlite.org/compile.html#yystackdepth for

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Hi Paul, > To me it seems like that string is very tightly coupled with the actual > pointer being bound. No, not really. The type string is tightly coupled with the extension module which uses the pointer. The type string allows the extension module to check whether the pointer is really

Re: [sqlite] sequencer

2017-08-03 Thread Sylvain Pointeau
On Thu, 3 Aug 2017 at 08:04, Hick Gunter wrote: > A sequence is very easily implemented as a virtual table that keeps the > current values in a separate table my_sequences (name text primary key, > initial integer, current integer, increment integer). > > (...) Or whatever else

[sqlite] Bug: Nested function call to replace() throws parser stack overflow exception

2017-08-03 Thread Brian Clifford
Hi, I've subscribed to the sqllite mailing list but am still awaiting authorization. I'd like to report a bug I found with sqlite where I'm creating a function index which consists of approx 36 nested calls to the replace() function (to remove punctuation) I get a parser stackoverflow exception

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Hi Clemens, > Ulrich Telle wrote: > > In the comment of the sqlite3_bind_pointer() routine I found this note: > > > > The T parameter should be a static string, preferably a string literal. > > > > In my case this is quite cumbersome, since in my wrapper I have to extract > > the value of

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Paul
To me it seems like that string is very tightly coupled with the actual pointer being bound. I think it's a good idea, in case you cannot make it a literal or static, to keep it with an object whose pointer you bind. Hi, I came across a problem with the new pointer-passing interface,

[sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Hi, I came across a problem with the new pointer-passing interface, when I tried to incorporate the carray extension into my wxSQLite3 wrapper for SQLite3. In the comment of the sqlite3_bind_pointer() routine I found this note: The T parameter should be a static string, preferably a string

Re: [sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Clemens Ladisch
Ulrich Telle wrote: > In the comment of the sqlite3_bind_pointer() routine I found this note: > > The T parameter should be a static string, preferably a string literal. > > In my case this is quite cumbersome, since in my wrapper I have to extract > the value of parameter T from a temporary

[sqlite] Problem with the new pointer-passing interface

2017-08-03 Thread Ulrich Telle
Hi, I came across a problem with the new pointer-passing interface, when I tried to incorporate the carray extension into my wxSQLite3 wrapper for SQLite3. In the comment of the sqlite3_bind_pointer() routine I found this note: The T parameter should be a static string, preferably a

Re: [sqlite] sqlite3_prepare16_v3 and prepFlags

2017-08-03 Thread Bart Smissaert
Not quite clear as point 9 in the release notes of 3.20.0 seems to me to suggest that this only applied if you are using FTS3, FTS5 or the R-Tree extension. RBS On Wed, Aug 2, 2017 at 11:09 PM, Nico Williams wrote: > On Wed, Aug 02, 2017 at 11:01:07PM +0100, Bart

Re: [sqlite] sequencer

2017-08-03 Thread Hick Gunter
A sequence is very easily implemented as a virtual table that keeps the current values in a separate table my_sequences (name text primary key, initial integer, current integer, increment integer). CREATE VIRTUAL TABLE seq_1 USING sequence ([[,]]); -- defaults 1, 1 The xCreate/xConnect