Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-07 Thread Joe Mucchiello
 I just want to point something out that might help the original poster.

On Saturday, March 7, 2020, 7:00:21 AM EST, 
sqlite-users-requ...@mailinglists.sqlite.org 
 wrote:  > 
> 1.  NULL is NULL = Yes, True,
> 2.  NULL is FALSE = Nope, False.
> 3.  NULL is TRUE  = Nope, False.
> 4.  NULL is NOT NULL = Nope, False,
> 5.  NULL is NOT FALSE = Yep, True.
> 6.  NULL is NOT TRUE = Yep, True.
> 7. TRUE is FALSE  = Nope, False.
> 8. TRUE is NOT FALSE = Yep, True.
> 9. FALSE is NOT TRUE = Yep, True.
This explanation 100% correct and probably 80% confusing without the following, 
especially because "is" is not capitalized:IS and IS NOT are logical operators 
in SQL. NOT is not a unary operator when preceded by IS.

In most non-relational languages "NULL IS NOT TRUE" is parsed as:

value(NULL) operator(IS) (operator(NOT) value(TRUE)). 

That is NOT how SQL works. In SQL, it is:

value(NULL) operator(IS NOT) value(TRUE).


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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread R.Smith

On 2020/03/07 03:52, Xinyue Chen wrote:

Hi,

If I change IS NOT FALSE to IS TRUE, the results will be different. I
assume they should perform in the same way?
if you say "NULL IS NOT FALSE" is always true, then 'NULL IS TRUE' should
also be always true. Then why doesn't that query also return 4 rows?


Some excellent answers were already given, but in case you still wonder...

In Boolean logic, a value can only be TRUE or FALSE. But in SQL (which 
has to model the real World Algebraically) there is also the possibility 
that the state is simply NOT KNOWN (or indeed that a 
variable/placeholder/identifier can represent no value at all).


The expression (Null = Null) is always NULL - it's like asking if an 
unknown person is exactly the same person as another unknown person? The 
answer is obviously "We don't know. It might be, so we cannot say 
definitively it ISN'T the case, but it might also NOT be the same 
person, so the only correct answer is: We don't know".
Further, "We don't know" in logic terms is undefined, which in SQL we 
write as "NULL".


While (Null = Null) in mathematical terms is always unknown, we can 
however test if two values are of the same kind with "is", and more 
specifically, test if they are both unknown, so the expression (NULL is 
NULL) correctly returns True.


This whole "Three possible states" thing is no longer simply Boolean 
logic, but indeed Trivalent logic with the possible values being 
NULL/TRUE/FALSE.


Writing the matrix of states of (x IS [NOT] y) down and numbering them 
we get 9 symantically distinct evaluations (there are more, like "FALSE 
is TRUE", but they can be rearranged as one of these):


1.  NULL is NULL = Yes, True,
2.  NULL is FALSE = Nope, False.
3.  NULL is TRUE  = Nope, False.
4.  NULL is NOT NULL = Nope, False,
5.  NULL is NOT FALSE = Yep, True.
6.  NULL is NOT TRUE = Yep, True.
7. TRUE is FALSE  = Nope, False.
8. TRUE is NOT FALSE = Yep, True.
9. FALSE is NOT TRUE = Yep, True.

Thus when you ask:
"I assume they should perform in the same way?
if you say "NULL IS NOT FALSE" is always true, then 'NULL IS TRUE' 
should also be always true. Then why doesn't that query also return 4 rows?"


You assume that state 5 (NULL IS NOT FALSE) and state 3 (NULL IS TRUE) 
would mean the same thing, but as you can see from the list, in 
Trivalent logic it clealy doesn't - one is False and the other is True.



The stuff of nightmares to a purist, I know. In the real World though, 
some stuff simply isn't known and therefore cannot fit into the simple 
Boolean logic of TRUE and FALSE.


Best of luck!
Ryan


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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Richard Damon

On 3/6/20 9:54 PM, Keith Medcalf wrote:

On Friday, 6 March, 2020 19:25, Richard Damon  wrote:


It is sort of like NaN, where a Nan is neither less than, greater than
or equal to any value, including itself.

NULL (as in SQL NULL) means "missing value" or "unknown".  NULL represents any value 
within the domain, we simply do not know what that value is.  That is, the value "NULL" for colour 
of a car means that we do not know the colour -- however, it still has one.

NaN, on the other hand, means that the value is outside the domain and that 
there is no possible value of the domain which well render the proposition true.

For example, the state of Schroedingers Cat is NULL.  It has a state, either 
dead or alive.  That state is merely unknown until one looks in the box.  
However, if when you looked in the box there was no cat, then the cat would be 
a NaN since its state was outside of the domain of states for a cat in a box 
with a time release poison after the release of the poison, that is, the 
non-existance of a cat in the box precludes the possibility of the state of the 
cat in the box being either either dead or alive.


It may have a different meaning, but similar effects on logic.

As an aside, for the quantum effect Schrodinger's Cat is designed to 
demonstrate, the cat ISN'T just one of dead or alive but not know which, 
but exists as a probability wave between the two states. This is why the 
photon which goes through one of two slits generates an interference 
pattern unless you detect which slit it goes through, if you measure the 
slit it went through, you get a different pattern of light, as the lack 
of knowledge allows it to be less precise in its position and the 
probability of going through the left slit interferes with the 
probability of that same particle going through the right slit, so the 
pattern implies it sort of went through both at once.


Detecting the state of Schrodinger's Cat actually changes its state, 
collapsing the wave into one of the definitive states.


--
Richard Damon

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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Keith Medcalf

On Friday, 6 March, 2020 19:25, Richard Damon  wrote:

>It is sort of like NaN, where a Nan is neither less than, greater than
>or equal to any value, including itself.

NULL (as in SQL NULL) means "missing value" or "unknown".  NULL represents any 
value within the domain, we simply do not know what that value is.  That is, 
the value "NULL" for colour of a car means that we do not know the colour -- 
however, it still has one.

NaN, on the other hand, means that the value is outside the domain and that 
there is no possible value of the domain which well render the proposition true.

For example, the state of Schroedingers Cat is NULL.  It has a state, either 
dead or alive.  That state is merely unknown until one looks in the box.  
However, if when you looked in the box there was no cat, then the cat would be 
a NaN since its state was outside of the domain of states for a cat in a box 
with a time release poison after the release of the poison, that is, the 
non-existance of a cat in the box precludes the possibility of the state of the 
cat in the box being either either dead or alive.

-- 
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] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Richard Damon

On 3/6/20 9:00 PM, Simon Slavin wrote:

On 7 Mar 2020, at 1:52am, Xinyue Chen  wrote:


If I change IS NOT FALSE to IS TRUE, the results will be different. I
assume they should perform in the same way?

No.  Because NULL is not TRUE and is not FALSE.

SQLite version 3.28.0 2019-04-15 14:49:49
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT NULL IS TRUE;
0
sqlite> SELECT NULL IS FALSE;
0
sqlite> SELECT NULL IS NOT TRUE;
1
sqlite> SELECT NULL IS NOT FALSE;
1

Once you can have NULL values, you have to know the rules very well when you 
apply logic.  Other values make sense, but NULL is not logical.
It is sort of like NaN, where a Nan is neither less than, greater than 
or equal to any value, including itself.


--
Richard Damon

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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Igor Tandetnik

On 3/6/2020 8:52 PM, Xinyue Chen wrote:

If I change IS NOT FALSE to IS TRUE, the results will be different.


NULL IS TRUE is always false. NULL IS NOT FALSE is always true. So it's not 
surprising that the results are different.

SQL uses trivalent logic. NULL is neither FALSE nor TRUE.


I assume they should perform in the same way?


You assume incorrectly.


if you say "NULL IS NOT FALSE" is always true, then 'NULL IS TRUE' should
also be always true.


False.
--
Igor Tandetnik

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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Simon Slavin
On 7 Mar 2020, at 1:52am, Xinyue Chen  wrote:

> If I change IS NOT FALSE to IS TRUE, the results will be different. I
> assume they should perform in the same way?

No.  Because NULL is not TRUE and is not FALSE.

SQLite version 3.28.0 2019-04-15 14:49:49
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT NULL IS TRUE;
0
sqlite> SELECT NULL IS FALSE;
0
sqlite> SELECT NULL IS NOT TRUE;
1
sqlite> SELECT NULL IS NOT FALSE;
1

Once you can have NULL values, you have to know the rules very well when you 
apply logic.  Other values make sense, but NULL is not logical.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Peter da Silva
> If I change IS NOT FALSE to IS TRUE, the results will be different. I
> assume they should perform in the same way?
> if you say "NULL IS NOT FALSE" is always true, then 'NULL IS TRUE' should
> also be always true.

"NULL IS NOT FALSE" is true because NULL is not a value therefor it is not 
FALSE, because FALSE is a value.
"NULL IS TRUE" is false because NULL is not a value so it's not TRUE.

You can't compare NULL with anything. All you can do is tell if it "IS NULL" or 
"IS NOT NULL".

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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Xinyue Chen
Hi,

If I change IS NOT FALSE to IS TRUE, the results will be different. I
assume they should perform in the same way?
if you say "NULL IS NOT FALSE" is always true, then 'NULL IS TRUE' should
also be always true. Then why doesn't that query also return 4 rows?
Thanks!

On Fri, Mar 6, 2020 at 5:45 PM Peter da Silva  wrote:

> Change the "(t1.textid = null)" to "(t1.textid IS NULL)". Null has no
> value, you have to check for it explicitly.
>
> ___
> 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] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Keith Medcalf

On Friday, 6 March, 2020 17:48 Xinyue Chen  wrote:

...

>select t1.textid a, i.intid b
>  from t t1,
>   i i
> where (t1.textid = i.intid and t1.textid in (12) and t1.textid = i.intid) 
>or (t1.textid = null IS NOT FALSE)
>group by i.intid, t1.textid;

I got rid of all the extra brackets to make this easier to read.

The where clause wants either (a bunch of and joined conditions) to be true OR 
(another condition to be true).  We will ignore the first set of AND joined 
conditions since they appear to do what you want and instead deal with the 
handling of NULL values and tri-state logic from the second OR joined 
condition, which appears to be the one causing problems.

The expression (t1.textid = null) is always null (it is neither True nor 
False), no matter what the value of t1.textid because any value compared to 
NULL is NULL.  If you want to know whether t1.textid is null then you write 
"t1.textid is null" or (conversely) "t1.textid is not null"

NULL is FALSE -> False (NULL is not False)
NULL is TRUE  -> False (NULL is not True either)
NULL is not FALSE -> True  (it is True that NULL is not FALSE)
NULL is not TRUE  -> True  (it is True that NULL is not TRUE)

Since the condition that you have specified (t1.textid = NULL) IS NOT FALSE 
will always be true, then the logic value of condition on the "other side" of 
the OR is irrelevant -- the WHERE clause will always be TRUE.  This condition 
holds for any not null value you use in place of TRUE or FALSE.  That is:

NULL is 1 -> False (NULL is not 1)
NULL is 0 -> False (NULL is not 0 either)
NULL is not 1 -> True  (NULL is indeed not 1)
NULL is not 2 -> True  (NULL is indeed not 2)

This result will be the same if you change the IS NOT FALSE to IS NOT TRUE.  
However, if you specify IS TRUE or IS FALSE then this expression will always be 
FALSE and the value of the WHERE clause will depend on the result of the first 
set of AND joined conditions.

So your original query must and always devolves to:

select t1.textid a, i.intid b
from t t1,
 i i
group by i.intid, t1.textid;

for which the correct results are produced.

-- 
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] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Peter da Silva
Change the "(t1.textid = null)" to "(t1.textid IS NULL)". Null has no value, 
you have to check for it explicitly.

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


Re: [sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Richard Hipp
On 3/6/20, Xinyue Chen  wrote:
> -- Buggy query
> select t1.textid a, i.intid b
> from t t1,
>  i i
> where (((t1.textid = i.intid) and (t1.textid in (12)) and (t1.textid =
> i.intid)) or ((t1.textid = null) IS NOT FALSE))
> group by i.intid, t1.textid;


(1) The expression "t1.textid=null" is always NULL.
(2) The expression "NULL IS NOT FALSE" is always true.
(3) The WHERE clause expression "... OR true" is always true.

Hence, the query above simplifies to just "SELECT * FROM t, i;".  That
query should return 4 rows, just as you show.  I think it is working
correctly.

-- 
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


[sqlite] Bug in SQLite version 3.31.1 and 3.32?

2020-03-06 Thread Xinyue Chen
Hi,

I am not sure if I found a bug in SQLite version 3.31.1 and 3.32. Could you
please check?

CREATE TABLE t (
  textid TEXT
);
INSERT INTO t
VALUES ('12');
INSERT INTO t
VALUES ('34');
CREATE TABLE i (
  intid INTEGER PRIMARY KEY
);
INSERT INTO i
VALUES (12);
INSERT INTO i
VALUES (34);
CREATE TABLE e (
  x INTEGER PRIMARY KEY NOT NULL,
  y TEXTNOT NULL
);
-- Original query
select t1.textid a, i.intid b
from t t1,
 i i
where ((t1.textid = i.intid) and (t1.textid = 12));
-- Buggy query
select t1.textid a, i.intid b
from t t1,
 i i
where (((t1.textid = i.intid) and (t1.textid in (12)) and (t1.textid =
i.intid)) or ((t1.textid = null) IS NOT FALSE))
group by i.intid, t1.textid;

The result for the original query is 12|12 but the result for the buggy one
is 12|12, 34|12, 12|34, 34|34. If I change the IS NOT FALSE to IS TRUE, the
result will be 12|12, same to the original query.

Thanks!

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


Re: [sqlite] bug report (INSTR() ignores NOCASE on columns)

2020-02-04 Thread Jose Isaias Cabrera

Stephan Senzel, on Sunday, February 2, 2020 08:12 AM, wrote...
>
> INSTR() ignores NOCASE on columns
>
> ---
>
> example:
>
> SELECT * FROM table WHERE INSTR(column, ' castle ') > 0
>
> returns datasets with 'castle' only, without 'Castle', even if the
> column is set to NOCASE

True statement with v3.31.0:
12:25:41.10>sqlite3
SQLite version 3.31.0 2020-01-22 18:38:59
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table t0(a string collate nocase);
sqlite> insert into t0 values ('In my castle I have...');
sqlite> insert into t0 values ('In my castle I have had...');
sqlite> insert into t0 values ('In my castle I''ve never had...');
sqlite> insert into t0 values ('In my Castle I have...');
sqlite> select a from t0 where INSTR(a,' castle') > 0;
In my castle I have...
In my castle I have had...
In my castle I've never had...
sqlite>


> LIKE doesn't have this problem, works well
>
> SELECT * FROM table WHERE column LIKE '% castle %'
>
> returns 'castle' and 'Castle' when column is set to NOCASE

Also true with v3.31.0:
sqlite> select a from t0 where a LIKE '% castle%';
In my castle I have...
In my castle I have had...
In my castle I've never had...
In my Castle I have...
sqlite>

Just making sure... :-)

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


[sqlite] bug report (INSTR() ignores NOCASE on columns)

2020-02-03 Thread Stephan Senzel

INSTR() ignores NOCASE on columns

---

example:

SELECT * FROM table WHERE INSTR(column, ' castle ') > 0

returns datasets with 'castle' only, without 'Castle', even if the 
column is set to NOCASE


---

LIKE doesn't have this problem, works well

SELECT * FROM table WHERE column LIKE '% castle %'

returns 'castle' and 'Castle' when column is set to NOCASE
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report: Potential thread safety issues in sqlite3_initialize

2020-01-28 Thread Oystein Eftevaag
As I understand it, the barrier in that patch ensures that for whichever
thread executes the if(!sqlite3GlobalConfig.mutex.xMutexAlloc codepath)
{...}, the write to pTo->xMutexAlloc will be stored after the rest of the
xMutex* field writes. But there's nothing preventing another thread
*loading* them out of order; e.g. loading an uninitialized
sqlite3GlobalConfig.mutex.xMutexInit into a register prior to loading a now
initialized sqlite3GlobalConfig.mutex.xMutexAlloc (hence skipping the if()
block  in sqlite3MutexInit()), which could effectively result in a
sqlite3MutexInit() call with sqlite3GlobalConfig.mutex.xMutexInit
still being null after (for some number of cycles).

https://gist.github.com/vinterstum/ff4bc1ea715cc1d4c5da45864c9de4af should
help I think.

On Tue, Jan 28, 2020 at 4:57 PM Richard Hipp  wrote:

> On 1/28/20, Oystein Eftevaag  wrote:
> > in sqlite3MutexInit() sqlite3GlobalConfig.mutex.xMutexAlloc
> > can be read as being set on a core, while the rest of the initialization
> > done in sqlite3MutexInit() still is being read as unset.
>
> Doesn't the memory barrier at
> https://www.sqlite.org/src/artifact/bae36f8af32c22ad?ln=247 prevent
> that?  Do you have a suggested patch to make it work?
>
>
> --
> 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] Bug report: Potential thread safety issues in sqlite3_initialize

2020-01-28 Thread Richard Hipp
On 1/28/20, Oystein Eftevaag  wrote:
> in sqlite3MutexInit() sqlite3GlobalConfig.mutex.xMutexAlloc
> can be read as being set on a core, while the rest of the initialization
> done in sqlite3MutexInit() still is being read as unset.

Doesn't the memory barrier at
https://www.sqlite.org/src/artifact/bae36f8af32c22ad?ln=247 prevent
that?  Do you have a suggested patch to make it work?


-- 
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


[sqlite] Bug report: Potential thread safety issues in sqlite3_initialize

2020-01-28 Thread Oystein Eftevaag
Hi folks,

Data races in sqlite3_initialize was previously reported in
https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg94225.html
and
a fix landed, however while investigating internal TSan reports of this, as
far as we can tell the issue is still present (on non-x86 platforms with
less memory ordering guarantees) as mentioned previously in
https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg94225.html
.

Specifically, in sqlite3MutexInit() sqlite3GlobalConfig.mutex.xMutexAlloc
can be read as being set on a core, while the rest of the initialization
done in sqlite3MutexInit() still is being read as unset. The same is true
for sqlite3GlobalConfig.isInit within sqlite3_initialize(); a core calling
the function concurrently with another, could see
sqlite3GlobalConfig.isInit as set while the rest of the init work done is
still seen as unset. This is due to the current memory barriers ordering
the writes, but there's no barriers ensuring that other cores haven't done
the loads out of order.

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


Re: [sqlite] BUG(?) in FTS5

2020-01-23 Thread mailing lists
Hi Jens,

the MATCH operator is not inside an OR expression. The MATCH operator is in an 
AND expression, only the rowid request is in an OR expression.

Regards,
Hartwig

PS: In FTS5 since version 3.30.1 also the MATCH operator is allowed in OR 
statements (try SELECT PlayersFTS.rowid FROM PlayersFTS WHERE (PlayersFTS MATCH 
'LastName:B') OR (PlayersFTS MATCH 'FirstNames:2');)

> Am 2020-01-23 um 17:51 schrieb Jens Alfke :
> 
> 
>> On Jan 23, 2020, at 6:47 AM, mailing lists  wrote:
>> 
>> The following SELECT statement fails with the error "unable to use function 
>> MATCH in the requested context":
> 
> This is an annoying but documented limitation of FTS, not a bug. The MATCH 
> operator can’t be used inside an OR expression. It has to be at top-level or 
> in an AND.
> 
> —Jens
> ___
> 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] Bug report

2020-01-23 Thread Warren Young
On Jan 23, 2020, at 7:02 AM, Mark Benningfield  wrote:
> 
> ...whenever I do a Fossil pull of the latest
> version takes a grand total of about 2 seconds, but it would be nice not to
> have to remember to do it every time :)

If you’re having to reapply the change on every Fossil update, you’re probably 
making the change to the wrong place in the code: you’re changing a generated 
file rather than a proper source file.

Saying “fossil up” or “fossil up release” should merge your local edits into 
the new release automatically unless upstream changes something nearby or on 
those same lines.

I don’t say this expecting that these problems will remain unfixed upstream, 
just as general forward-looking advice.  Fossil can be a useful aide in 
carrying local changes from one release to the next.

There are more advanced methods beyond that, such as private branches and 
autosync=0, but at that point we should take it up on the Fossil forum.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] BUG(?) in FTS5

2020-01-23 Thread Jens Alfke

> On Jan 23, 2020, at 6:47 AM, mailing lists  wrote:
> 
> The following SELECT statement fails with the error "unable to use function 
> MATCH in the requested context":

This is an annoying but documented limitation of FTS, not a bug. The MATCH 
operator can’t be used inside an OR expression. It has to be at top-level or in 
an AND.

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


[sqlite] BUG(?) in FTS5

2020-01-23 Thread mailing lists
Hi,

create and fill the tables:

CREATE TABLE Games (ID INTEGER PRIMARY KEY, WhiteID INTEGER, BlackID INTEGER);
CREATE VIRTUAL TABLE PlayersFTS USING FTS5 (LastName,FirstNames);

INSERT INTO Games (WhiteID,BlackID) VALUES(1,2);
INSERT INTO PlayersFTS (rowid,LastName,FirstNames) VALUES(1,'A','1');
INSERT INTO PlayersFTS (rowid,LastName,FirstNames) VALUES(2,'B','2');

The following SELECT statement fails with the error "unable to use function 
MATCH in the requested context":

SELECT Games.* FROM Games,PlayersFTS WHERE 
((PlayersFTS.rowid=Games.BlackID)OR(PlayersFTS.rowid=Games.WhiteID))AND(PlayersFTS
 MATCH 'LastName:A');

This SELECT statement works:

SELECT Games.* FROM Games,PlayersFTS WHERE (PlayersFTS.rowid 
IN(Games.BlackID,Games.WhiteID))AND(PlayersFTS MATCH 'LastName:A');

Regards,
Hartwig

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


Re: [sqlite] Bug report

2020-01-23 Thread Mark Benningfield
Well, I kinda thought that this would be fixed on the next release. The
"value_frombind" typo in particular prevents FTS3/4 from being built as a
loadable extension. I only have one legacy application that uses FTS3/4 that
way, and fixing these typos whenever I do a Fossil pull of the latest
version takes a grand total of about 2 seconds, but it would be nice not to
have to remember to do it every time :)



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] bug on zPath length

2020-01-23 Thread Richard Hipp
On 1/23/20, Ondrej Dubaj  wrote:
> I discovered an issue found by coverity scan.

Thanks for the report.  This was previously fixed here:
https://www.sqlite.org/src/info/465a15c5c2077011


-- 
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


[sqlite] bug on zPath length

2020-01-23 Thread Ondrej Dubaj
Hi,

I discovered an issue found by coverity scan.
sqlite-src-326/shell.c:5697: var_compare_op: Comparing "zFree" to null
implies that "zFree" might be null.
sqlite-src-326/shell.c:5698: alias_transfer: Assigning: "zPath" =
"zFree".
sqlite-src-326/shell.c:5699: var_deref_model: Passing null pointer
"zPath" to "strlen", which dereferences it.
# 5697| if( zFree==0 ){ rc = SQLITE_NOMEM; }
# 5698| zPath = (const char*)zFree;
# 5699|-> nPath = (int)strlen(zPath);
# 5700| }
# 5701| }

It sais that ZPath can be NULL during strlen() action. I have made a patch,
which seems to solve this issue. Can you please confirm or discomfirm my
cheanges?

diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c
index e6141ef..1f214a4 100644
--- a/ext/misc/zipfile.c
+++ b/ext/misc/zipfile.c
@@ -1630,9 +1630,12 @@ static int zipfileUpdate(
** otherwise. */
if( zPath[nPath-1]!='/' ){
zFree = sqlite3_mprintf("%s/", zPath);
- if( zFree==0 ){ rc = SQLITE_NOMEM; }
- zPath = (const char*)zFree;
- nPath = (int)strlen(zPath);
+ if( zFree==0 ){
+ rc = SQLITE_NOMEM;
+ } else {
+ zPath = (const char*)zFree;
+ nPath = (int)strlen(zPath);
+ }
}
}
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug? SQLITE_DEFAULT_DEFENSIVE and CLI .parameters

2020-01-19 Thread Keith Medcalf

Defining SQLITE_DEFAULT_DEFENSIVE prevents proper working of the CLI .parameter 
commands.

SQLite version 3.31.0 2020-01-19 18:49:07
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .schema
sqlite> .param init
sqlite> .schema
sqlite> .param set :test test
Error: no such table: temp.sqlite_parameters
sqlite> CREATE TEMP TABLE sqlite_parameters(key TEXT PRIMARY KEY, value);
Error: object name reserved for internal use: sqlite_parameters

-- 
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] Bug fixes only branch.

2020-01-13 Thread Richard Hipp
On 1/13/20, Syed Ahmad  wrote:
> We are at 3.14.2
>
> Current version = 3.14.2 Date : 2016-09-12
>
> https://www.sqlite.org/changes.html
>
> how can i take latest stable branch which include only bug fixes . no new
> features.
>
> Is there any way?

We sometimes do things like that for paid support customers.  But
maintaining bug-fix branches of historical versions is time-consuming,
so we do not do it routinely.  It is also risky, as actual releases
are better tested and more reliable than backported patches.

-- 
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] Bug fixes only branch.

2020-01-13 Thread Keith Medcalf

On Monday, 13 January, 2020 15:00, Donald Griggs  wrote:

>On Mon, Jan 13, 2020 at 11:34 AM Syed Ahmad  
>wrote:

>> We are at 3.14.2   Date : 2016-09-12

>> how can i take latest stable branch which include only bug fixes . no
>> new features.

>> Is there any way?

> I may well not be understanding properly, but what motivates you to ask
> for this?

I would suspect that the motivation is a periodic risk re-assessment policy 
that has been either badly written or is being badly interpreted in the belief 
that the addition of "new features" that are unused to a component that is 
subject to risk assessment requires an assessment of the risk associated with 
the unused "new features".  In other words, the risk assessment is based on the 
version of something rather than the utilized functionality of something.

This is quite common and in my previous job (before retirement) significant 
resources were spent on unnecessarily re-assessing things just because the 
version number changed (which often meant that things were not updated in order 
to prevent this expensive process), rather than simply reviewing the existing 
Risk Assessment and determining that nothing had changed, and that the addition 
of new unused "features" was immaterial to the overall assessment.

That is, someone had generated a Risk Assessment based (for example) on the use 
of SQLite version 3.14.2 and that the mere act of updating the version triggers 
the process for the re-evaluation of the Risk of the new version in toto, 
including the Risk associated with "features available" rather than "features 
used", when in fact the update of the version (and the addition of new unused 
and inaccessible features) was quite irrelevant.

A significant amount of effort was expended globally (probably on the order of 
hundreds of thousands of man-hours at not insignificant engineering cost per 
hour) to remove "version numbers" from Risk Assessments and to make sure that 
they were based on functionality used/exposed rather than the version number 
itself.

In this example, the difference is that someone believes that (for example) 
because the current version of SQLite supports CTE's and the old one didn't, 
requires an assessment of the risk associated with CTEs, even though the 
specific use being assessed does not and cannot use CTE's, thus triggering a 
full assessment of Risk (including the unused CTE feature) rather than merely a 
review to determine whether or not there been any significant change to the 
risk profile which would require re-assessment.

In other words, if the "old" version of something only supported "red" and 
"blue", and the system only used "red", and a subsequent version added "green" 
without affecting the functionality of "red" (and that "blue" and "green" are 
not used and cannot be accessed) then the mere fact of the addition of the 
feature "green" is irrelevant (until such time as the feature "green" is used, 
of course).  The fact that the new thing "green" is available is merely a 
quaint observation of zero significance if (a) it is not used and (b) cannot be 
meaningfully accessed, and its addition is not a significant change to the risk 
of that something.

-- 
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] Bug fixes only branch.

2020-01-13 Thread Donald Shepherd
On Tue, 14 Jan 2020 at 7:00 am, Donald Griggs  wrote:

> Hi, Syed,
>
> ===
> On Mon, Jan 13, 2020 at 11:34 AM Syed Ahmad 
> wrote:
>
> > We are at 3.14.2   Date : 2016-09-12
> >
> > how can i take latest stable branch which include only bug fixes . no new
> > features.
> >
> > Is there any way?
> > ==
>
>
> I may well not be understanding properly, but what motivates you to ask for
> this?
> Since the sqlite team spends so much effort to ensure backward
> compatibility, how bad would things be if you simply updated to the current
> stable release?
>
> The team does allow many features to be eliminated through conditional
> compilation if you are severely constrained in RAM.   Was RAM size the
> motivation?
>
> To provide versions which include only bug fixes from any arbitrary
> releasee, I should think the developers would, for every stable release,
> have to maintain a new fixes-only branch indefinitely -- and thus have to
> maintain dozens of branches.   Am I missing something?
>
> Kind regards,
>Donald
> ___


I can't speak to his exact scenario but having spent time in a very risk
averse work environment, I've experienced this kind of thinking.

The logic is almost always as a result of "we must have low bug counts
(true) so we need bug fixes (true) but new features introduce bugs (in
general true) therefore we don't want any new features".

In other words it's a result of the environment rather than a reflection of
SQLite.

Regards,
Donald Shepherd.

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


Re: [sqlite] Bug fixes only branch.

2020-01-13 Thread Donald Griggs
Hi, Syed,

===
On Mon, Jan 13, 2020 at 11:34 AM Syed Ahmad 
wrote:

> We are at 3.14.2   Date : 2016-09-12
>
> how can i take latest stable branch which include only bug fixes . no new
> features.
>
> Is there any way?
> ==


I may well not be understanding properly, but what motivates you to ask for
this?
Since the sqlite team spends so much effort to ensure backward
compatibility, how bad would things be if you simply updated to the current
stable release?

The team does allow many features to be eliminated through conditional
compilation if you are severely constrained in RAM.   Was RAM size the
motivation?

To provide versions which include only bug fixes from any arbitrary
releasee, I should think the developers would, for every stable release,
have to maintain a new fixes-only branch indefinitely -- and thus have to
maintain dozens of branches.   Am I missing something?

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


[sqlite] Bug fixes only branch.

2020-01-13 Thread Syed Ahmad
We are at 3.14.2

Current version = 3.14.2 Date : 2016-09-12

https://www.sqlite.org/changes.html

how can i take latest stable branch which include only bug fixes . no new
features.

Is there any way?
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-07 Thread Igor Korot
Hi,

On Tue, Jan 7, 2020 at 2:01 AM Clemens Ladisch  wrote:
>
> Richard Hipp wrote:
> > On 1/5/20, Keith Medcalf  wrote:
> >> select * from a, b, c using (id); -- very strange result
> >
> > PostgreSQL and MySQL process the query as follows:
> >
> >SELECT * FROM a, (b JOIN c USING(id));
> >
> > SQLite processes the query like this:
> >
> >SELECT * FROM (a,b) JOIN c USING (id);
> >
> > I don't know which is correct.  Perhaps the result is undefined.
>
> Assuming the following query:
>
>   SELECT * FROM a, b JOIN c USING (id);
>
> SQL-92 says:
> |7.4  
> |
> | ::= FROM  [ {   reference> }... ]
> |
> |6.3  
> |
> | ::=
> |[ [ AS ] 
> |   [] ]
> | |  [ AS ] 
> |   []
> | | 
> |
> |7.5  
> |
> | ::=
> |   
> | | 
> | |   
> |
> | ::=
> |  CROSS JOIN 
> |
> | ::=
> |  [ NATURAL ] [  ] JOIN
> |[  ]
>
> It is not possible to have such a  inside a , so
> b and c must be joined first.
>
> SQLite actually parses the comma as a join:
>
>   SELECT * FROM a CROSS JOIN b JOIN c USING (id);
>
> If the query were written like this, joining a and b first would be
> correct.  (As far as I can see, the standard does not say how to handle
> ambiguous parts of the grammar, so it would also be allowed to produce
> "b JOIN c" first.)

That's why one should never use that "MS JOIN extension" and should
simply write:

SELECT ... FROM a,b,c WHERE a.x = b.x AND b.x = c.y AND...;

Thank you.

>
>
> Regards,
> Clemens
> ___
> 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] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-07 Thread Clemens Ladisch
Richard Hipp wrote:
> On 1/5/20, Keith Medcalf  wrote:
>> select * from a, b, c using (id); -- very strange result
>
> PostgreSQL and MySQL process the query as follows:
>
>SELECT * FROM a, (b JOIN c USING(id));
>
> SQLite processes the query like this:
>
>SELECT * FROM (a,b) JOIN c USING (id);
>
> I don't know which is correct.  Perhaps the result is undefined.

Assuming the following query:

  SELECT * FROM a, b JOIN c USING (id);

SQL-92 says:
|7.4  
|
| ::= FROM  [ {   
}... ]
|
|6.3  
|
| ::=
|[ [ AS ] 
|   [] ]
| |  [ AS ] 
|   []
| | 
|
|7.5  
|
| ::=
|   
| | 
| |   
|
| ::=
|  CROSS JOIN 
|
| ::=
|  [ NATURAL ] [  ] JOIN
|[  ]

It is not possible to have such a  inside a , so
b and c must be joined first.

SQLite actually parses the comma as a join:

  SELECT * FROM a CROSS JOIN b JOIN c USING (id);

If the query were written like this, joining a and b first would be
correct.  (As far as I can see, the standard does not say how to handle
ambiguous parts of the grammar, so it would also be allowed to produce
"b JOIN c" first.)


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


Re: [sqlite] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-05 Thread Keith Medcalf

On Sunday, 5 January, 2020 04:42, Richard Hipp  wrote:

>On 1/5/20, Keith Medcalf  wrote:

>> Hrm.  Inconsistent/incorrect results.  Consider:

>> create table a(id integer primary key, a);
>> insert into a values (1,1), (2,1), (3,1);
>> create table b(id integer primary key, b);
>> insert into b values (1,2), (3,2), (4,2);
>> create table c(id integer primary key, c);
>> insert into c values (1,3), (4,3), (5,3);

>> select * from a, b, c using (id); -- very strange result

>> id  a   id  b   c
>> --  --  --  --  --
>> 1   1   1   2   3
>> 1   1   3   2   3
>> 1   1   4   2   3

>PostgreSQL and MySQL process the query as follows:

>   SELECT * FROM a, (b JOIN c USING(id));

>SQLite processes the query like this:

>   SELECT * FROM (a,b) JOIN c USING (id);

>I don't know which is correct.  Perhaps the result is undefined.

>Note that both MySQL and SQLite do allow you to use parentheses, as
>shown in my examples, to define the order of evaluation.  PostgreSQL
>does not, sadly.

>MS-SQL does not (as far as I can tell) support the USING syntax on a
>join.

Aha!  So as far as SQLite is concerned the syntax "... JOIN  USING ()" is 
effectively binding the using expression for the nested nested loop descent 
into into table  only and does not bind against the immediately preceeding 
LHS JOIN table.  

By adding some indexes and order by that cause the nesting order to change it 
appear that "a, b join c using (id)" is always processed as selecting the first 
lexically named id column irrepective of nesting order (that is "a, b join c 
using (id)" always becomes "a, b, c where a.id == c.id" and that "b, a join c 
using (id)" always becomes "a, b, c where b.id == c.id" even when the optimizer 
chooses to re-arrange the nesting order (such as by additional indexes and 
order by's)).

Since the "id" column to use is ambiguous for descent into "c" should not an 
"ambiguous column name" error be thrown?  The ambiguity only does not exist if 
ALL columns named "id" (for all tables that could be in an outer loop 
respective to "c") are constrained equal -- that is a,b,c using (id) -> a, b, c 
where a.id == b.id and a.id == c.id and b.id == c.id.

Since "natural join" devolves into a using, does not the same problem exist 
there as well?

Since any change is likely to have an effect on already existing and functional 
applications, could the behaviour be documented somewhere perhaps?

-- 
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] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-05 Thread Amer Neely
> On 1/5/20, Keith Medcalf  wrote:
>>
>> Hrm.  Inconsistent/incorrect results.  Consider:
>>
>> create table a(id integer primary key, a);
>> insert into a values (1,1), (2,1), (3,1);
>> create table b(id integer primary key, b);
>> insert into b values (1,2), (3,2), (4,2);
>> create table c(id integer primary key, c);
>> insert into c values (1,3), (4,3), (5,3);
>>
>> select * from a, b, c using (id); -- very strange result
>>
>> id  a   id  b   c
>> --  --  --  --  --
>> 1   1   1   2   3
>> 1   1   3   2   3
>> 1   1   4   2   3
> 
> PostgreSQL and MySQL process the query as follows:
> 
>SELECT * FROM a, (b JOIN c USING(id));
> 
> SQLite processes the query like this:
> 
>SELECT * FROM (a,b) JOIN c USING (id);
> 
> I don't know which is correct.  Perhaps the result is undefined.
> 
> Note that both MySQL and SQLite do allow you to use parentheses, as
> shown in my examples, to define the order of evaluation.  PostgreSQL
> does not, sadly.
> 
> MS-SQL does not (as far as I can tell) support the USING syntax on a join.
> 
> -- 
> D. Richard Hipp
> d...@sqlite.org

Ahh. More to learn. Thank you for the use of parentheses, I will have to
check my queries for that.

i did manage to get the query working by grouping on artists.artistid.
-- 
Amer Neely
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-05 Thread Richard Hipp
On 1/5/20, Richard Hipp  wrote:
>
> Note that both MySQL and SQLite do allow you to use parentheses, as
> shown in my examples, to define the order of evaluation.  PostgreSQL
> does not, sadly.
>

Apparently, in PostgreSQL you have to say:

   SELECT * FROM (SELECT * FROM a, b) AS x JOIN c USING(id);

-- 
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] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-05 Thread Richard Hipp
On 1/5/20, Keith Medcalf  wrote:
>
> Hrm.  Inconsistent/incorrect results.  Consider:
>
> create table a(id integer primary key, a);
> insert into a values (1,1), (2,1), (3,1);
> create table b(id integer primary key, b);
> insert into b values (1,2), (3,2), (4,2);
> create table c(id integer primary key, c);
> insert into c values (1,3), (4,3), (5,3);
>
> select * from a, b, c using (id); -- very strange result
>
> id  a   id  b   c
> --  --  --  --  --
> 1   1   1   2   3
> 1   1   3   2   3
> 1   1   4   2   3

PostgreSQL and MySQL process the query as follows:

   SELECT * FROM a, (b JOIN c USING(id));

SQLite processes the query like this:

   SELECT * FROM (a,b) JOIN c USING (id);

I don't know which is correct.  Perhaps the result is undefined.

Note that both MySQL and SQLite do allow you to use parentheses, as
shown in my examples, to define the order of evaluation.  PostgreSQL
does not, sadly.

MS-SQL does not (as far as I can tell) support the USING syntax on a join.

-- 
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


[sqlite] Bug? SQLite command-line result is different from Perl DBI::Sqlite result

2020-01-04 Thread Keith Medcalf

Hrm.  Inconsistent/incorrect results.  Consider:

create table a(id integer primary key, a);
insert into a values (1,1), (2,1), (3,1);
create table b(id integer primary key, b);
insert into b values (1,2), (3,2), (4,2);
create table c(id integer primary key, c);
insert into c values (1,3), (4,3), (5,3);

select * from a, b, c using (id); -- very strange result

id  a   id  b   c
--  --  --  --  --
1   1   1   2   3
1   1   3   2   3
1   1   4   2   3

select * from a, b using (id), c using (id); -- correct result

id  a   b   c
--  --  --  --
1   1   2   3

The first query should be processed as:

select * from a, b, c where b.id == c.id;

id  a   id  b   id  c
--  --  --  --  --  --
1   1   1   2   1   3
2   1   1   2   1   3
3   1   1   2   1   3
1   1   4   2   4   3
2   1   4   2   4   3
3   1   4   2   4   3

but with the c.id (third id column omitted).

Or it should be processed as the second query if the "using (id)" constraint 
applies to everywhere an "id" field is found, not just the LHS and RHS tables 
of the immediately proceeding join.

also 
select * from a natural join b natural join c;
-- returns no rows despite the column "id" existing commonly in all tables

This is with the current development release (and as far as I can tell, all 
prior versions).

-- 
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  On
>Behalf Of Keith Medcalf
>Sent: Saturday, 4 January, 2020 19:32
>To: SQLite mailing list 
>Subject: Re: [sqlite] SQLite command-line result is different from Perl
>DBI::Sqlite result
>
>
>
>
>
>--
>The fact that there's a Highway to Hell but only a Stairway to Heaven
>says a lot about anticipated traffic volume.
>
>On Saturday, 4 January, 2020 18:31, Amer Neely 
>wrote:
>
>>I'm fairly new to SQLite, but have been using MySQL / mariadb in a local
>>and web-based environment for several years. So far I'm happy and
>>impressed with SQLite, but I recently noticed some odd behaviour with
>>one of my queries.
>>Using the command-line in a shell (Mac High Sierra) I get a particular
>>result from a query. The exact same query in a Perl script gives me a
>>different result. To my mind it is a simple query, getting the 5 latest
>>additions to my music library.
>>Command-line:
>>select artists.artist, artists.artistid, cds.title, cds.artistid,
>>cds.cdid, genres.genre, genres.artistid from artists, genres inner join
>>cds using (artistid) group by artists.artistid order by cds.id desc
>>limit 5;
>>gives me the correct result. However, in a Perl script it gives me a
>>different result. How is that possible? Could it be a Perl::DBI issue?
>>Many thanks for anyone able to shed some light on this.
>
>Your select does not constrain artists so the result is non-deterministic
>in that the result will depend on how the query planner decides to
>execute the query.  That is, you have not specified any join constraints
>on artists.
>
>SELECT * FROM A, B JOIN C USING (D);
>
>means
>
>SELECT *
>  FROM A, B, C
> WHERE B.D == C.D;
>
>if you thought it meant
>
>SELECT *
>  FROM A, B, C
> WHERE A.D == B.D
>   AND B.D == C.D;
>
>then that is likely the reason for the discrepancy.
>
>
>
>
>___
>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] Bug Report

2019-12-30 Thread Jose Isaias Cabrera

Bigthing Do, on Friday, December 27, 2019 01:56 PM, wrote...
>
> Dear sqlite developers:
>
> We met an accidental crash in sqlite with the following sample:
>
> CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM table1
> ) SELECT col2 FROM table1 ORDER BY 1 ;
> WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER BY
> col1 DESC ) FROM table1 ;
>
>
> We are using release version of sqlite: `SQLite version 3.30.1 2019-10-10
> 20:19:45`

Also with 3.30.0...

16:41:27.70>sqlite3
SQLite version 3.30.0 2019-10-04 15:03:17
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM 
table1 ) SELECT col2 FROM table1 ORDER BY 1 ;
sqlite> WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER 
BY col1 DESC ) FROM table1 ;

16:42:07.53>

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


Re: [sqlite] Bug Report

2019-12-27 Thread Bigthing Do
Hi,

We tried debugging a little bit with the core dump, it crashes with a null 
reference actually:

`
Program received signal SIGSEGV, Segmentation fault.
[--registers---]
RAX: 0x74 ('t')
RBX: 0x782550 --> 0x76b088 --> 0x1
RCX: 0x61 ('a')
RDX: 0x0
RSI: 0x0
RDI: 0x782098 --> 0x31656c626174 ('table1')
RBP: 0x782548 --> 0x10001
RSP: 0x7fffb6b0 --> 0x78d1b0 --> 0x78d1e8 --> 0x50804496
RIP: 0x4b4237 (:movzx  ecx,BYTE PTR [rdx+rsi*1])
R8 : 0x77d0e8 --> 0x1
R9 : 0x0
R10: 0x77d0f8 --> 0x0
R11: 0x0
R12: 0x1
R13: 0x7fffc680 --> 0x76a9b8 --> 0x73c300 --> 0x780003
R14: 0x7fffc680 --> 0x76a9b8 --> 0x73c300 --> 0x780003
R15: 0x0
EFLAGS: 0x10246 (carry PARITY adjust ZERO sign trap INTERRUPT direction 
overflow)
[-code-]
   0x4b422d :   jne0x4b4270 
   0x4b422f :   addrsi,0x1
   0x4b4233 :   movzx  eax,BYTE PTR [rdi+rsi*1]
=> 0x4b4237 :   movzx  ecx,BYTE PTR [rdx+rsi*1]
`

We got the same result if we debug with address sanitizer, not an out of memory 
error.


Thanks,
Ming Jia

> On Dec 27, 2019, at 2:56 PM, Keith Medcalf  wrote:
> 
> 
> On Friday, 27 December, 2019 12:50, Igor Korot  wrote:
> 
>> On Fri, Dec 27, 2019 at 12:57 PM Bigthing Do  wrote:
> 
>>> We met an accidental crash in sqlite with the following sample:
> 
>>> CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM table1 ) 
>>> SELECT col2 FROM table1 ORDER BY 1 ;
>>> WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER BY 
>>> col1 DESC ) FROM table1 ;
> 
>> Could you please provide the schema for table1?
> 
> table1 is a circular view ... that is table1 is a view that tries to select 
> from table1 which is a view which selects from table1 which is a view which 
> selects from table1 ... until eventually all memory and stack is consumed and 
> sqlite crashes.
> 
> -- 
> 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

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


Re: [sqlite] Bug Report

2019-12-27 Thread Keith Medcalf

On Friday, 27 December, 2019 12:50, Igor Korot  wrote:

>On Fri, Dec 27, 2019 at 12:57 PM Bigthing Do  wrote:

>> We met an accidental crash in sqlite with the following sample:

>> CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM table1 ) 
>> SELECT col2 FROM table1 ORDER BY 1 ;
>> WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER BY 
>> col1 DESC ) FROM table1 ;

>Could you please provide the schema for table1?

table1 is a circular view ... that is table1 is a view that tries to select 
from table1 which is a view which selects from table1 which is a view which 
selects from table1 ... until eventually all memory and stack is consumed and 
sqlite crashes.

-- 
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] Bug Report

2019-12-27 Thread Igor Korot
Hi,

On Fri, Dec 27, 2019 at 12:57 PM Bigthing Do  wrote:
>
> Dear sqlite developers:
>
> We met an accidental crash in sqlite with the following sample:
>
> CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM table1 ) 
> SELECT col2 FROM table1 ORDER BY 1 ;
> WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER BY 
> col1 DESC ) FROM table1 ;

Could you please provide the schema for table1?

Thank you.

>
>
> We are using release version of sqlite: `SQLite version 3.30.1 2019-10-10 
> 20:19:45`
>
> Thanks
>
> Ming Jia
> ___
> 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] Bug Report

2019-12-27 Thread Bigthing Do
Dear sqlite developers:

We met an accidental crash in sqlite with the following sample: 

CREATE VIEW table1 ( col1 , col2 ) AS WITH aaa AS ( SELECT * FROM table1 ) 
SELECT col2 FROM table1 ORDER BY 1 ;
WITH aaa AS ( SELECT * FROM table1 ) SELECT col1 , rank () OVER( ORDER BY col1 
DESC ) FROM table1 ;


We are using release version of sqlite: `SQLite version 3.30.1 2019-10-10 
20:19:45`

Thanks

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


Re: [sqlite] Bug: Table contains two records for the same primary key in .dump output but not in SELECT output

2019-12-21 Thread Tim Streater
On 21 Dec 2019, at 21:42, Michael Walker (barrucadu)  
wrote:

> I'm not sure the attachment to my first email got through ...

Correct. The list strips them.



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


Re: [sqlite] Bug: Table contains two records for the same primary key in .dump output but not in SELECT output

2019-12-21 Thread Shawn Wagner
The mailing list strips attachments, btw.

Anyways, looking at that, yeah, they're all text values:

sqlite> SELECT bookIsbn, typeof(bookIsbn) FROM books WHERE bookAuthor LIKE
'%Ambrose%';
bookIsbntypeof(bookIsbn)
--  
0486280381  text
9781496030  text
9781496030  text

There are other problems with the database too:

sqlite> PRAGMA integrity_check;
integrity_check
---
row 649 missing from index sqlite_autoindex_books_1
row 659 missing from index sqlite_autoindex_books_1
row 665 missing from index sqlite_autoindex_books_1
row 667 missing from index sqlite_autoindex_books_1
row 674 missing from index sqlite_autoindex_books_1
row 676 missing from index sqlite_autoindex_books_1

I'd start going through https://www.sqlite.org/howtocorrupt.html and trying
to figure out if anything there might have happened.


On Sat, Dec 21, 2019 at 1:43 PM Michael Walker (barrucadu) <
m...@barrucadu.co.uk> wrote:

> Hi Shawn,
>
> Thanks for your response.  Though that doesn't seem to be the case:
>
> sqlite> select bookIsbn, typeof(bookIsbn) from books where bookIsbn =
> "9781496030825";
> 9781496030825|text
> sqlite> select bookIsbn, typeof(bookIsbn) from books where bookIsbn =
> "9780099477310";
> 9780099477310|text
>
> The column is a VARCHAR:
>
> CREATE TABLE `books` (
>`bookIsbn` VARCHAR NOT NULL PRIMARY KEY,
>`bookTitle` VARCHAR NOT NULL,
>`bookSubtitle` VARCHAR NOT NULL,
>`bookCover` VARCHAR NULL,
>`bookVolume` VARCHAR NOT NULL,
>`bookFascicle` VARCHAR NOT NULL,
>`bookVoltitle` VARCHAR NOT NULL,
>`bookAuthor` VARCHAR NOT NULL,
>`bookTranslator` VARCHAR NULL,
>`bookEditor` VARCHAR NULL,
>`bookSorting` VARCHAR NULL,
>`bookRead` BOOLEAN NOT NULL,
>`bookLastRead` TIMESTAMP NULL,
>`bookNowReading` BOOLEAN NOT NULL,
>`bookLocation` VARCHAR NOT NULL,
>`bookBorrower` VARCHAR NOT NULL,
>`bookCategoryCode` VARCHAR NOT NULL,
>FOREIGN KEY(`bookCategoryCode`) REFERENCES
> `book_categories`(`categoryCode`)
> );
>
> I'm not sure the attachment to my first email got through, so here's the
> database:
> https://misc.barrucadu.co.uk/forever/82e5584a-e4a8-4804-8abe-8f00be73f725/bookdb.sqlite
>
>
> ‐‐‐ Original Message ‐‐‐
> On Saturday, 21 December 2019 21:37, Shawn Wagner 
> wrote:
>
> > Without seeing your table definition, this is just a guess, but maybe the
> > duplicate keys are stored as different types, with the primary key column
> > having an affinity that doesn't force one particular storage class:
> >
> > sqlite> CREATE TABLE test(id PRIMARY KEY);
> > sqlite> INSERT INTO test VALUES('12345');
> > sqlite> INSERT INTO test VALUES(12345);
> > sqlite> SELECT id, typeof(id) FROM test;
> > id typeof(id)
> >
> > 12345 text
> > 12345 integer
> > sqlite> SELECT id, typeof(id) FROM test WHERE id = '12345';
> > id typeof(id)
> >
> > 12345 text
> >
> > On Sat, Dec 21, 2019 at 1:26 PM Michael Walker (barrucadu) <
> > m...@barrucadu.co.uk> wrote:
> >
> > > Hi,
> > > I've somehow ended up with a table which contains two records for the
> same
> > > primary key - well actually I've got two primary keys like that, so I
> have
> > > four records with two primary keys between them.
> > > I've been unable to reproduce this from a clean database, so I attach
> my
> > > database file to this email.
> > > Here are some oddities:
> > >
> > > $ sqlite3 bookdb.sqlite
> > > SQLite version 3.28.0 2019-04-16 19:49:53
> > > Enter ".help" for usage hints.
> > > sqlite> select * from books where bookIsbn = "9781496030825";
> > > 9781496030825|Can Such Things Be?||9781496030825.jpgBierce,
> > > Ambrose0||0|London||F
> > > sqlite> select * from books where bookIsbn = "9780099477310";
> > > 9780099477310|Catch-22||9780099477310.jpgHeller,
> > > Joseph0||0|London||F
> > > sqlite> .output books_issue
> > > sqlite> .dump books
> > > sqlite> .quit
> > >
> > > $ grep "9781496030825" < books_issue
> > > INSERT INTO books VALUES('9781496030825','Can Such Things
> > > Be?','','9781496030825.jpg','','','','Bierce,
> > > Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > > INSERT INTO books VALUES('9781496030825','Can Such Things
> > > Be?','','9781496030825.jpg','','','','Bierce,
> > > Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > >
> > > $ grep "9780099477310" < books_issue
> > > INSERT INTO books
> > >
>  VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> > > Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > > INSERT INTO books
> > >
>  VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> > > Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > >
> > > $ sqlite3 bookdb.sqlite
> > > SQLite version 3.28.0 2019-04-16 19:49:53
> > > Enter ".help" for usage 

Re: [sqlite] Bug: Table contains two records for the same primary key in .dump output but not in SELECT output

2019-12-21 Thread Michael Walker (barrucadu)
Hi Shawn,

Thanks for your response.  Though that doesn't seem to be the case:

sqlite> select bookIsbn, typeof(bookIsbn) from books where bookIsbn = 
"9781496030825";
9781496030825|text
sqlite> select bookIsbn, typeof(bookIsbn) from books where bookIsbn = 
"9780099477310";
9780099477310|text

The column is a VARCHAR:

CREATE TABLE `books` (
   `bookIsbn` VARCHAR NOT NULL PRIMARY KEY,
   `bookTitle` VARCHAR NOT NULL,
   `bookSubtitle` VARCHAR NOT NULL,
   `bookCover` VARCHAR NULL,
   `bookVolume` VARCHAR NOT NULL,
   `bookFascicle` VARCHAR NOT NULL,
   `bookVoltitle` VARCHAR NOT NULL,
   `bookAuthor` VARCHAR NOT NULL,
   `bookTranslator` VARCHAR NULL,
   `bookEditor` VARCHAR NULL,
   `bookSorting` VARCHAR NULL,
   `bookRead` BOOLEAN NOT NULL,
   `bookLastRead` TIMESTAMP NULL,
   `bookNowReading` BOOLEAN NOT NULL,
   `bookLocation` VARCHAR NOT NULL,
   `bookBorrower` VARCHAR NOT NULL,
   `bookCategoryCode` VARCHAR NOT NULL,
   FOREIGN KEY(`bookCategoryCode`) REFERENCES 
`book_categories`(`categoryCode`)
);

I'm not sure the attachment to my first email got through, so here's the 
database: 
https://misc.barrucadu.co.uk/forever/82e5584a-e4a8-4804-8abe-8f00be73f725/bookdb.sqlite


‐‐‐ Original Message ‐‐‐
On Saturday, 21 December 2019 21:37, Shawn Wagner  
wrote:

> Without seeing your table definition, this is just a guess, but maybe the
> duplicate keys are stored as different types, with the primary key column
> having an affinity that doesn't force one particular storage class:
>
> sqlite> CREATE TABLE test(id PRIMARY KEY);
> sqlite> INSERT INTO test VALUES('12345');
> sqlite> INSERT INTO test VALUES(12345);
> sqlite> SELECT id, typeof(id) FROM test;
> id typeof(id)
>
> 12345 text
> 12345 integer
> sqlite> SELECT id, typeof(id) FROM test WHERE id = '12345';
> id typeof(id)
>
> 12345 text
>
> On Sat, Dec 21, 2019 at 1:26 PM Michael Walker (barrucadu) <
> m...@barrucadu.co.uk> wrote:
>
> > Hi,
> > I've somehow ended up with a table which contains two records for the same
> > primary key - well actually I've got two primary keys like that, so I have
> > four records with two primary keys between them.
> > I've been unable to reproduce this from a clean database, so I attach my
> > database file to this email.
> > Here are some oddities:
> >
> > $ sqlite3 bookdb.sqlite
> > SQLite version 3.28.0 2019-04-16 19:49:53
> > Enter ".help" for usage hints.
> > sqlite> select * from books where bookIsbn = "9781496030825";
> > 9781496030825|Can Such Things Be?||9781496030825.jpgBierce,
> > Ambrose0||0|London||F
> > sqlite> select * from books where bookIsbn = "9780099477310";
> > 9780099477310|Catch-22||9780099477310.jpgHeller,
> > Joseph0||0|London||F
> > sqlite> .output books_issue
> > sqlite> .dump books
> > sqlite> .quit
> >
> > $ grep "9781496030825" < books_issue
> > INSERT INTO books VALUES('9781496030825','Can Such Things
> > Be?','','9781496030825.jpg','','','','Bierce,
> > Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > INSERT INTO books VALUES('9781496030825','Can Such Things
> > Be?','','9781496030825.jpg','','','','Bierce,
> > Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
> >
> > $ grep "9780099477310" < books_issue
> > INSERT INTO books
> > 
> > VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> > Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
> > INSERT INTO books
> > 
> > VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> > Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
> >
> > $ sqlite3 bookdb.sqlite
> > SQLite version 3.28.0 2019-04-16 19:49:53
> > Enter ".help" for usage hints.
> > sqlite> drop table books;
> > sqlite>
> >
> > $ sqlite3 bookdb.sqlite < books_issue
> > Error: near line 697: UNIQUE constraint failed: books.bookIsbn
> > Error: near line 698: UNIQUE constraint failed: books.bookIsbn
> >
> >
> > Updating either affected record results in the second copy in the .dump
> > output being updated, the first copy has the original state.
> > The table has always had a primary key constraint, so I'm not sure how
> > it's ended up in its current state. However, even if there were not a
> > primary key constraint, there do seem to be two very real bugs here: SELECT
> > gives different results to .dump, and .dump is producing output which can't
> > be restored.
> > I'm not sure if you'll be able to make anything of this, as I say I
> > haven't been able to reproduce it from a blank database, but I figure
> > you'll be better at debugging this than me.
> > Thanks
> > --
> > Michael Walker (http://www.barrucadu.co.uk)
> >
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> sqlite-users mailing list
> 

Re: [sqlite] Bug: Table contains two records for the same primary key in .dump output but not in SELECT output

2019-12-21 Thread Shawn Wagner
Without seeing your table definition, this is just a guess, but maybe the
duplicate keys are stored as different types, with the primary key column
having an affinity that doesn't force one particular storage class:

sqlite> CREATE TABLE test(id PRIMARY KEY);
sqlite> INSERT INTO test VALUES('12345');
sqlite> INSERT INTO test VALUES(12345);
sqlite> SELECT id, typeof(id) FROM test;
id  typeof(id)
--  --
12345   text
12345   integer
sqlite> SELECT id, typeof(id) FROM test WHERE id = '12345';
id  typeof(id)
--  --
12345   text



On Sat, Dec 21, 2019 at 1:26 PM Michael Walker (barrucadu) <
m...@barrucadu.co.uk> wrote:

> Hi,
>
> I've somehow ended up with a table which contains two records for the same
> primary key - well actually I've got two primary keys like that, so I have
> four records with two primary keys between them.
>
> I've been unable to reproduce this from a clean database, so I attach my
> database file to this email.
>
> Here are some oddities:
>
> ```
> $ sqlite3 bookdb.sqlite
> SQLite version 3.28.0 2019-04-16 19:49:53
> Enter ".help" for usage hints.
> sqlite> select * from books where bookIsbn = "9781496030825";
> 9781496030825|Can Such Things Be?||9781496030825.jpgBierce,
> Ambrose0||0|London||F
> sqlite> select * from books where bookIsbn = "9780099477310";
> 9780099477310|Catch-22||9780099477310.jpgHeller,
> Joseph0||0|London||F
> sqlite> .output books_issue
> sqlite> .dump books
> sqlite> .quit
>
> $ grep "9781496030825" < books_issue
> INSERT INTO books VALUES('9781496030825','Can Such Things
> Be?','','9781496030825.jpg','','','','Bierce,
> Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
> INSERT INTO books VALUES('9781496030825','Can Such Things
> Be?','','9781496030825.jpg','','','','Bierce,
> Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
>
> $ grep "9780099477310" < books_issue
> INSERT INTO books
> VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
> INSERT INTO books
> VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller,
> Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
>
> $ sqlite3 bookdb.sqlite
> SQLite version 3.28.0 2019-04-16 19:49:53
> Enter ".help" for usage hints.
> sqlite> drop table books;
> sqlite>
>
> $ sqlite3 bookdb.sqlite < books_issue
> Error: near line 697: UNIQUE constraint failed: books.bookIsbn
> Error: near line 698: UNIQUE constraint failed: books.bookIsbn
> ```
>
> Updating either affected record results in the second copy in the .dump
> output being updated, the first copy has the original state.
>
> The table has always had a primary key constraint, so I'm not sure how
> it's ended up in its current state.  However, even if there were not a
> primary key constraint, there do seem to be two very real bugs here: SELECT
> gives different results to .dump, and .dump is producing output which can't
> be restored.
>
> I'm not sure if you'll be able to make anything of this, as I say I
> haven't been able to reproduce it from a blank database, but I figure
> you'll be better at debugging this than me.
>
> Thanks
>
> --
> Michael Walker (http://www.barrucadu.co.uk)
> ___
> 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] Bug: Table contains two records for the same primary key in .dump output but not in SELECT output

2019-12-21 Thread Michael Walker (barrucadu)
Hi,

I've somehow ended up with a table which contains two records for the same 
primary key - well actually I've got two primary keys like that, so I have four 
records with two primary keys between them.

I've been unable to reproduce this from a clean database, so I attach my 
database file to this email.

Here are some oddities:

```
$ sqlite3 bookdb.sqlite
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
sqlite> select * from books where bookIsbn = "9781496030825";
9781496030825|Can Such Things Be?||9781496030825.jpgBierce, 
Ambrose0||0|London||F
sqlite> select * from books where bookIsbn = "9780099477310";
9780099477310|Catch-22||9780099477310.jpgHeller, Joseph0||0|London||F
sqlite> .output books_issue
sqlite> .dump books
sqlite> .quit

$ grep "9781496030825" < books_issue
INSERT INTO books VALUES('9781496030825','Can Such Things 
Be?','','9781496030825.jpg','','','','Bierce, 
Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');
INSERT INTO books VALUES('9781496030825','Can Such Things 
Be?','','9781496030825.jpg','','','','Bierce, 
Ambrose',NULL,NULL,NULL,0,NULL,0,'London','','F');

$ grep "9780099477310" < books_issue
INSERT INTO books 
VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller, 
Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');
INSERT INTO books 
VALUES('9780099477310','Catch-22','','9780099477310.jpg','','','','Heller, 
Joseph',NULL,NULL,NULL,0,NULL,0,'London','','F');

$ sqlite3 bookdb.sqlite
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
sqlite> drop table books;
sqlite>

$ sqlite3 bookdb.sqlite < books_issue
Error: near line 697: UNIQUE constraint failed: books.bookIsbn
Error: near line 698: UNIQUE constraint failed: books.bookIsbn
```

Updating either affected record results in the second copy in the .dump output 
being updated, the first copy has the original state.

The table has always had a primary key constraint, so I'm not sure how it's 
ended up in its current state.  However, even if there were not a primary key 
constraint, there do seem to be two very real bugs here: SELECT gives different 
results to .dump, and .dump is producing output which can't be restored.

I'm not sure if you'll be able to make anything of this, as I say I haven't 
been able to reproduce it from a blank database, but I figure you'll be better 
at debugging this than me.

Thanks

--
Michael Walker (http://www.barrucadu.co.uk)
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug report

2019-12-16 Thread Mark Benningfield
In version 3.30.1 ( check-in  [9b14eb77] ), file "sqlite3ext.h"

618  #define sqlite3_stmt_isexplain sqlite3_api->isexplain
619  #define sqlite3_value_frombind sqlite3_api->frombind

should be

618  #define sqlite3_stmt_isexplain sqlite3_api->stmt_isexplain
619  #define sqlite3_value_frombind sqlite3_api->value_frombind

Errors:
"isexplain" is not a member of struct sqlite3_api
"frombind" is not a member of struct sqlite3_api



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report: cppcheck memory leak

2019-12-01 Thread Simon Slavin
On 2 Dec 2019, at 1:16am, Richard Hipp  wrote:

> Telling us that the
> "return" from malloc() is a memory leak is not helpful information,
> even if it were true.

Oh, someone needs to write a story about a manager who doesn't understand 
computers but relies on test suites, and programmers trying to convince them 
that there are good reasons to fail tests.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report: cppcheck memory leak

2019-12-01 Thread Richard Hipp
On 12/1/19, David Brouwer  wrote:
> While playing around with static code analysis with cppcheck, I ran into
> the error "[modules/sqlite3_omit.c:22845]: (error) Memory leak: p". I can't
> tell whether it's significant or not, but I figured I'd report it anyway.

Thanks for taking the time to report it.  But this is not a helpful bug report.

(1) Static analyzers are notorious for giving false-positive
indications in SQLite.  Furthermore, SQLite is very intensely tested
for memory leaks, and memory leaks are rare.  The chance of a static
analyzer finding a memory leak, even if one were in the code, is very
small.  Given the high proportion of false-positives coming from
static analyzers, one can safely disbelieve any reports of memory
leaks that lack corroborating evidence.

(2) The line number listed is the "return" from an internal SQLite
routine that is a wrapper around malloc().  Telling us that the
"return" from malloc() is a memory leak is not helpful information,
even if it were true.

-- 
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


[sqlite] Bug report: cppcheck memory leak

2019-12-01 Thread David Brouwer
Dear,

Title: Potential memory leak reported by cppcheck
Version: 3.27.2

While playing around with static code analysis with cppcheck, I ran into
the error "[modules/sqlite3_omit.c:22845]: (error) Memory leak: p". I can't
tell whether it's significant or not, but I figured I'd report it anyway.

The line number for the report is 22845 in version 3.27.2
The line number for the report is 23065 in version 3.30.1

Kind regards,
David Brouwer
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report

2019-11-21 Thread Simon Slavin
CVE will not record this bug if it doesn't affect a /released/ version of any 
product.  One hopes that none of the products which incorporate SQLite would 
incorporate a version of SQLite which never received a release number.

In other words, the reporters told the developer team before the bug became a 
problem.  Very good.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report

2019-11-21 Thread Kees Nuyt
On Thu, 21 Nov 2019 21:02:57 +, Jose Isaias Cabrera wrote:

>Kees Nuyt, on Thursday, November 21, 2019 03:48 PM, wrote...
[...]
>>
>> I see no CVE entered by the OP, but maybe I missed something.
>
> Yes, you are right.  After pasting it, I went through the top 5
> and none of these aren't/weren't the one. Apologies. 
> I thought that by searching on sqlite the top 5 or so
> would be the one that was just opened, but for some reason,
> it was not.  Sorry about that.  Fast fingers Jose.

No problem!
We'll wait for more input from the OP.

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


Re: [sqlite] Bug report

2019-11-21 Thread Jose Isaias Cabrera

Kees Nuyt, on Thursday, November 21, 2019 03:48 PM, wrote...
>
>
> Thanks, Jose.
>
> I see no CVE entered by the OP, but maybe I missed something.

Yes, you are right.  After pasting it, I went through the top 5 and none of 
these aren't/weren't the one. Apologies.  I thought that by searching on sqlite 
the top 5 or so would be the one that was just opened, but for some reason, it 
was not.  Sorry about that.  Fast fingers Jose.

josé

> A quick look to your list :
>
> > NameDescription
> > CVE-2019-9937, on
> > In SQLite 3.27.2, interleaving reads and writes in a single transaction with
> > an fts5 virtual table will lead to a NULL Pointer Dereference in
> > fts5ChunkIterate in sqlite3.c. This is related to ext/fts5/fts5_hash.c and
> > ext/fts5/fts5_index.c.
>
> Resolved 2019-03-18
>
>
> > CVE-2019-9936, on
> > In SQLite 3.27.2, running fts5 prefix queries inside a transaction could
> > trigger a heap-based buffer over-read in fts5HashEntrySort in sqlite3.c, 
> > which
> > may lead to an information leak. This is related to ext/fts5/fts5_hash.c.
>
> Resolved 2019-03-18
>
>
> > CVE-2019-5827, on
> > Integer overflow in SQLite via WebSQL in Google Chrome prior to 
> > 74.0.3729.131
> > allowed a remote attacker to potentially exploit heap corruption via a 
> > crafted
> > HTML page.
>
> Resolved 2019-04-13
>
>
> > CVE-2019-3784, on
> > Cloud Foundry Stratos, versions prior to 2.3.0, contains an insecure session
> > that can be spoofed. When deployed on cloud foundry with multiple instances
> > using the default embedded SQLite database, a remote authenticated malicious
> > user can switch sessions to another user with the same session id.
>
> Application error
>
>
> > CVE-2019-1616 
> > 8
> > In SQLite through 3.29.0, whereLoopAddBtreeIndex in sqlite3.c can crash a
> > browser or other application because of missing validation of a sqlite_stat1
> > sz field, aka a "severe division by zero in the query planner."
>
> Resolved 2019-08-15
>
>
> > CVE-2019-1075 
> > 2
> > Sequelize, all versions prior to version 4.44.3 and 5.15.1, is vulnerable to
> > SQL Injection due to sequelize.json() helper function not escaping values
> > properly when formatting sub paths for JSON queries for MySQL, MariaDB and
> > SQLite.
>
> Application error
>
>
> > CVE-2018-8740, on
> > In SQLite through 3.22.0, databases whose schema is corrupted using a CREATE
> > TABLE AS statement could cause a NULL pointer dereference, related to 
> > build.c
> > and prepare.c.
>
> Resolved 2018-03-16
>
>
> > CVE-2018-7774, on
> > The vulnerability exists within processing of localize.php in Schneider
> > Electric U.motion Builder software versions prior to v1.3.4. The underlying
> > SQLite database query is subject to SQL injection on the username input
> > parameter.
>
> Application error
>
>
> --
> Regards,
> Kees Nuyt
> ___
> 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] Bug report

2019-11-21 Thread Kees Nuyt

Thanks, Jose.

I see no CVE entered by the OP, but maybe I missed something.

A quick look to your list :

> NameDescription
> CVE-2019-9937 
> In SQLite 3.27.2, interleaving reads and writes in a single transaction with
> an fts5 virtual table will lead to a NULL Pointer Dereference in
> fts5ChunkIterate in sqlite3.c. This is related to ext/fts5/fts5_hash.c and
> ext/fts5/fts5_index.c.

Resolved 2019-03-18


> CVE-2019-9936 
> In SQLite 3.27.2, running fts5 prefix queries inside a transaction could
> trigger a heap-based buffer over-read in fts5HashEntrySort in sqlite3.c, which
> may lead to an information leak. This is related to ext/fts5/fts5_hash.c.

Resolved 2019-03-18


> CVE-2019-5827 
> Integer overflow in SQLite via WebSQL in Google Chrome prior to 74.0.3729.131
> allowed a remote attacker to potentially exploit heap corruption via a crafted
> HTML page.

Resolved 2019-04-13


> CVE-2019-3784 
> Cloud Foundry Stratos, versions prior to 2.3.0, contains an insecure session
> that can be spoofed. When deployed on cloud foundry with multiple instances
> using the default embedded SQLite database, a remote authenticated malicious
> user can switch sessions to another user with the same session id.

Application error


> CVE-2019-1616 8
> In SQLite through 3.29.0, whereLoopAddBtreeIndex in sqlite3.c can crash a
> browser or other application because of missing validation of a sqlite_stat1
> sz field, aka a "severe division by zero in the query planner."

Resolved 2019-08-15


> CVE-2019-1075 2
> Sequelize, all versions prior to version 4.44.3 and 5.15.1, is vulnerable to
> SQL Injection due to sequelize.json() helper function not escaping values
> properly when formatting sub paths for JSON queries for MySQL, MariaDB and
> SQLite.

Application error


> CVE-2018-8740 
> In SQLite through 3.22.0, databases whose schema is corrupted using a CREATE
> TABLE AS statement could cause a NULL pointer dereference, related to build.c
> and prepare.c.

Resolved 2018-03-16


> CVE-2018-7774 
> The vulnerability exists within processing of localize.php in Schneider
> Electric U.motion Builder software versions prior to v1.3.4. The underlying
> SQLite database query is subject to SQL injection on the username input
> parameter.

Application error


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


Re: [sqlite] Bug report

2019-11-21 Thread Richard Hipp
On 11/19/19, Yongheng Chen  wrote:
> Hi,
>
> This is Yongheng Chen from Gatech and Rui Zhong from PSU. We found 7 crashes
> for sqlite of  the newest commit 3842e8f166e23a1ed6e6094105e7a23502d414da.
> We have attached the samples that crash sqlite in the email. FYI, we have
> also reported the bugs for CVE at cve.mitre.org .

There were just two bugs, both related to the new (unreleased)
generated column feature.  Both have now been fixed on trunk.  Thank
you for the bug reports.

In as much as these problems have never appeared in a released version
of SQLite, I think a CVE would be inappropriate.  But I don't really
understand CVEs so perhaps I am wrong.

Please consider following SQLite development on the official
source-code repository.  You can see the latest changes here:

https://sqlite.org/src/timeline

If you click on any of the check-in hashes, that will take you to a
page that contains links to download tarballs and/or ZIP archives of
the latest code.  Or you can use Fossil to clone the repository.  See
https://www.sqlite.org/getthecode.html for additional information
about how to get the official SQLite source code.

The filenames of your test cases suggest that they were generated by
AFL.  How did you find these issues?  Do you have new and enhanced AFL
fuzzer, perhaps one in which you have replaced the default mutator
with an SQL-language generator?  Can you tell us more about your new
fuzzer?

-- 
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] Bug report

2019-11-21 Thread Jose Isaias Cabrera

NameDescription
CVE-2019-9937<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9937>  
In SQLite 3.27.2, interleaving reads and writes in a single transaction with an 
fts5 virtual table will lead to a NULL Pointer Dereference in fts5ChunkIterate 
in sqlite3.c. This is related to ext/fts5/fts5_hash.c and ext/fts5/fts5_index.c.
CVE-2019-9936<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9936>  
In SQLite 3.27.2, running fts5 prefix queries inside a transaction could 
trigger a heap-based buffer over-read in fts5HashEntrySort in sqlite3.c, which 
may lead to an information leak. This is related to ext/fts5/fts5_hash.c.
CVE-2019-5827<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5827>  
Integer overflow in SQLite via WebSQL in Google Chrome prior to 74.0.3729.131 
allowed a remote attacker to potentially exploit heap corruption via a crafted 
HTML page.
CVE-2019-3784<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3784>  
Cloud Foundry Stratos, versions prior to 2.3.0, contains an insecure session 
that can be spoofed. When deployed on cloud foundry with multiple instances 
using the default embedded SQLite database, a remote authenticated malicious 
user can switch sessions to another user with the same session id.
CVE-2019-16168<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-16168>
In SQLite through 3.29.0, whereLoopAddBtreeIndex in sqlite3.c can crash a 
browser or other application because of missing validation of a sqlite_stat1 sz 
field, aka a "severe division by zero in the query planner."
CVE-2019-10752<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-10752>
Sequelize, all versions prior to version 4.44.3 and 5.15.1, is vulnerable to 
SQL Injection due to sequelize.json() helper function not escaping values 
properly when formatting sub paths for JSON queries for MySQL, MariaDB and 
SQLite.
CVE-2018-8740<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8740>  
In SQLite through 3.22.0, databases whose schema is corrupted using a CREATE 
TABLE AS statement could cause a NULL pointer dereference, related to build.c 
and prepare.c.
CVE-2018-7774<http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-7774>  
The vulnerability exists within processing of localize.php in Schneider 
Electric U.motion Builder software versions prior to v1.3.4. The underlying 
SQLite database query is subject to SQL injection on the username input 
parameter.



From: sqlite-users  on behalf of 
Kees Nuyt 
Sent: Thursday, November 21, 2019 09:51 AM
To: sqlite-users@mailinglists.sqlite.org 
Subject: Re: [sqlite] Bug report

On Tue, 19 Nov 2019 00:19:13 -0500, you wrote:

> Hi,
>
> This is Yongheng Chen from Gatech and Rui Zhong from PSU.
> We found 7 crashes for sqlite of  the newest commit
> 3842e8f166e23a1ed6e6094105e7a23502d414da.
> We have attached the samples that crash sqlite in the email.

The mailing list strips attachemnts. Please insert them in the body text of your
message, or mail them to Richard Hipp.

> FYI, we have also reported the bugs for CVE
> at cve.mitre.org <http://cve.mitre.org/>.

Can you tell us the CVE nunber?


--
Regards,

Kees Nuyt

___
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] Bug report

2019-11-21 Thread Kees Nuyt
On Tue, 19 Nov 2019 00:19:13 -0500, you wrote:

> Hi,
>
> This is Yongheng Chen from Gatech and Rui Zhong from PSU.
> We found 7 crashes for sqlite of  the newest commit
> 3842e8f166e23a1ed6e6094105e7a23502d414da. 
> We have attached the samples that crash sqlite in the email. 

The mailing list strips attachemnts. Please insert them in the body text of your
message, or mail them to Richard Hipp.

> FYI, we have also reported the bugs for CVE
> at cve.mitre.org . 

Can you tell us the CVE nunber?


-- 
Regards,

Kees Nuyt

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


[sqlite] Bug report

2019-11-21 Thread Yongheng Chen
Hi,

This is Yongheng Chen from Gatech and Rui Zhong from PSU. We found 7 crashes 
for sqlite of  the newest commit 3842e8f166e23a1ed6e6094105e7a23502d414da. We 
have attached the samples that crash sqlite in the email. FYI, we have also 
reported the bugs for CVE at cve.mitre.org . 

Thanks,

Yongheng & Rui

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


Re: [sqlite] BUG and WORKAROUND sqlite3 shell .parameter command evaluating arguments when it shouldn't.

2019-11-15 Thread Keith Medcalf

I think this is a bug.  However, looking at the code the way to achieve that is 
to surround the string in double quotes which will cause exactly what appears 
between the double-quotes to be stored.  I think it is because of the way the 
parsing and mprintf function works ...

sqlite> .param init
sqlite> .parameter set :date "'2019-11-15'"
sqlite> .param list
:date '2019-11-15'
sqlite> select :date;
2019-11-15
sqlite> select datetime(:date);
2019-11-15 00:00:00


-- 
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  On
>Behalf Of Shawn Wagner
>Sent: Friday, 15 November, 2019 10:15
>To: SQLite mailing list 
>Subject: [sqlite] sqlite3 shell .parameter command evaluating arguments
>when it shouldn't.
>
>Consider:
>
>sqlite> .parameter init
>sqlite> .parameter set :date '2019-11-15'
>sqlite> .parameter list
>:date 1993
>
>How do I make it treat the value argument as a string and not as a
>numeric
>expression that gets evaluated?
>___
>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] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread Keith Medcalf

On Friday, 1 November, 2019 10:20, Simon Slavin  wrote:

>On 1 Nov 2019, at 4:17pm, Simon Slavin  wrote:

>WHERE (c1 IS NULL) OR (C1 != 2)

> which could quite reasonably return rows.  However, the NULL possibility
> may be redundant.  I can't tell without tests.

The expression NOT (c1 IS NOT NULL AND c1 == 2)
is equivalent to c1 IS NULL OR c1 != 2
is equivalent to (c1 IS NOT 2)
or the original proper expression NOT (C1 IS 2)

and arises from the use of the '==' and '!=' rather that IS and IS NOT, and 
generating work-arounds to handle NULLs.  Work-arounds for handling NULLs are 
only required for non-equality tests since there is no standard operators 
handling nulls for the other comparison operators > < >= <=

-- 
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] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread Keith Medcalf

On Friday, 1 November, 2019 09:12, And Clover  wrote:

> CREATE TABLE t0 (c0);
> CREATE TABLE t1 (c1);
> INSERT INTO t0 VALUES (1);
> SELECT c0
> FROM t0 LEFT JOIN t1 ON c1=c0
> WHERE NOT (c1 IS NOT NULL AND c1=2);

>Expected result: (1)
>Actual result: no rows returned
>
>This appears to be a regression in 3.30; 3.29 and earlier give the
>expected result.

SQLite version 3.31.0 2019-11-01 16:38:18
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>  CREATE TABLE t0 (c0);
sqlite>  CREATE TABLE t1 (c1);
sqlite>  INSERT INTO t0 VALUES (1);
sqlite>  SELECT c0
   ...>  FROM t0 LEFT JOIN t1 ON c1=c0
   ...>  WHERE NOT (c1 IS NOT NULL AND c1=2);
1

Appears to be fixed in the current tip ...

-- 
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] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread And Clover

On 01/11/2019 16:20, Simon Slavin wrote:

It is actually
WHERE (c1 IS NULL) OR (C1 != 2)
which could quite reasonably return rows.


Yes, and with this OR filter the quoted example does indeed return rows. 
The version with:


WHERE NOT (c1 IS NOT NULL AND c1=2)

*should* be equivalent to your version, but in 3.30 does not return the 
NULL values.


> You can't possibly mean to do that WHERE clause in production code

I might not spell it like that myself, but a code generator would do it 
(and much worse!). This example was simplified from a query generated by 
a Django ORM queryset using `.exclude(nullable_joined_table__column=1)`, 
for instance.


But yeah, expressions written in a less-than-tasteful style should 
probably still work as specified by SQL92. ;-)


--
And Clover
mailto:a...@doxdesk.com
https://www.doxdesk.com/
gtalk:chat?jid=bobi...@gmail.com

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


Re: [sqlite] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread Simon Slavin
On 1 Nov 2019, at 4:17pm, Simon Slavin  wrote:

> This is a cut-down example, right ?  You can't possibly mean to do that WHERE 
> clause in production code.  It amounts to
> 
>WHERE (c1 IS NULL) AND (C1 != 2)

I'm so sorry.  It is actually

WHERE (c1 IS NULL) OR (C1 != 2)

which could quite reasonably return rows.  However, the NULL possibility may be 
redundant.  I can't tell without tests.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread Simon Slavin
On 1 Nov 2019, at 3:12pm, And Clover  wrote:

>WHERE NOT (c1 IS NOT NULL AND c1=2);
> 
> Expected result: (1)
> Actual result: no rows returned

This is a cut-down example, right ?  You can't possibly mean to do that WHERE 
clause in production code.  It amounts to

WHERE (c1 IS NULL) AND (C1 != 2)

I don't know how SQLite will evaluate that for all cases but I wouldn't be 
surprised to find zero rows returned.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug submission: left join filter on negated expression including NOTNULL

2019-11-01 Thread And Clover

Hi,

CREATE TABLE t0 (c0);
CREATE TABLE t1 (c1);
INSERT INTO t0 VALUES (1);
SELECT c0
FROM t0 LEFT JOIN t1 ON c1=c0
WHERE NOT (c1 IS NOT NULL AND c1=2);

Expected result: (1)
Actual result: no rows returned

This appears to be a regression in 3.30; 3.29 and earlier give the 
expected result.


Reproduced on Windows builds sqlite-dll-win32-x86-3300100, 
sqlite-dll-win64-x64-3300100 and sqlite-dll-win64-x64-330 (via 
Python sqlite3).


cheers,

--
And Clover
mailto:a...@doxdesk.com
https://www.doxdesk.com/
gtalk:chat?jid=bobi...@gmail.com

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


Re: [sqlite] Bug: Infite loop on SELECT with .explain on

2019-10-26 Thread Keith Medcalf

While on errata for the shell, there is a little cosmetic bugaboo with the 
output of .eqp full:

(1) When .mode col is in effect the "explain" column widths are used, not the 
.width or the defaults used when .eqp full is not in effect.
(2) .head on is ignored -- table output column headers are not output.

Also, if you give .eqp or .explain a nonsense argument they report that the 
argument must be a boolean.  .explain also appears to take auto and .eqp also 
takes more than just a boolean (eg full).

-- 
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  On
>Behalf Of Richard Hipp
>Sent: Saturday, 26 October, 2019 10:08
>To: SQLite mailing list 
>Subject: Re: [sqlite] Bug: Infite loop on SELECT with .explain on
>
>Thanks for the report.  This problem is fixed on trunk.
>
>To be clear, this is an issue in the "sqlite3" shell command, not in
>the SQLite core.
>
>Also, it is an issue in the deprecated and undocumented ".explain on"
>command of the shell.  Years ago, it used to be necessary to run
>".explain on" prior to running an EXPLAIN query in order to set up the
>output formatting correctly so that the EXPLAIN output was readable.
>But that setup is now done automatically.  There is no need to run
>".explain on" any more and that dot-command is now deprecated and
>undocumented.  It exists only to prevent legacy scripts from blowing
>up.  Perhaps I should make the ".explain" command into a no-op?
>--
>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



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


Re: [sqlite] Bug: Infite loop on SELECT with .explain on

2019-10-26 Thread Richard Hipp
Thanks for the report.  This problem is fixed on trunk.

To be clear, this is an issue in the "sqlite3" shell command, not in
the SQLite core.

Also, it is an issue in the deprecated and undocumented ".explain on"
command of the shell.  Years ago, it used to be necessary to run
".explain on" prior to running an EXPLAIN query in order to set up the
output formatting correctly so that the EXPLAIN output was readable.
But that setup is now done automatically.  There is no need to run
".explain on" any more and that dot-command is now deprecated and
undocumented.  It exists only to prevent legacy scripts from blowing
up.  Perhaps I should make the ".explain" command into a no-op?
-- 
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


[sqlite] Bug: Infite loop on SELECT with .explain on

2019-10-26 Thread Jan Schlien
I am running sqlite3 on a Linux Mint 18 desktop.

I first realized the problem with the stock sqlite3 client 3.11.0
2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f.

I confirmed it still exists with the currently published most recent
version 3.30.1 2019-10-10 20:19:45
18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b

Steps to reproduce:

--
$ sqlite3
SQLite version 3.30.1 2019-10-10 20:19:45
Enter ".help" for usage hints.

sqlite> create table feedback (fid integer primary key autoincrement,
cid integer not null references characters, game_number integer not null
default 1, players integer not null default 2, playtime text check
(playtime in ("kurz", "20-30", "30-45", "45-60", "lang")),
beginning_player boolean, liked integer, duration integer, luckiness
integer, complexity integer, rules integer, rule_suggestions text,
budget integer, text text);

sqlite> insert into feedback values (1, 1, 1, 2, "kurz", 1, 10, 3, 2, 3,
9, NULL, 10, NULL);

sqlite> select * from feedback;
1|1|1|2|kurz|1|10|3|2|3|9||10|

sqlite> .explain on
sqlite> select * from feedback;
--

This triggers an infinite loop. It uses a full cpu. strace shows it is
doing write(1, ""..., 1024) repeatedly (spaces).

gdb shows the following stack (no debug symbols in the sqlite binary
unfortunately):

(gdb) bt
#0  0xf7fd7fe9 in __kernel_vsyscall ()
#1  0xf7e4fb93 in write () from /lib/i386-linux-gnu/libc.so.6
#2  0xf7de30b1 in _IO_file_write () from /lib/i386-linux-gnu/libc.so.6
#3  0xf7de23e4 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4  0xf7de412d in _IO_do_write () from /lib/i386-linux-gnu/libc.so.6
#5  0xf7de4518 in _IO_file_overflow () from /lib/i386-linux-gnu/libc.so.6
#6  0xf7de379e in _IO_file_xsputn () from /lib/i386-linux-gnu/libc.so.6
#7  0xf7dd95f5 in _IO_padn () from /lib/i386-linux-gnu/libc.so.6
#8  0xf7dbd6b7 in vfprintf () from /lib/i386-linux-gnu/libc.so.6
#9  0xf7dc3668 in fprintf () from /lib/i386-linux-gnu/libc.so.6
#10 0x080ea46b in ?? ()
#11 0x080eb033 in ?? ()
#12 0x080eccc9 in ?? ()
#13 0x080ed698 in ?? ()
#14 0x080f5e8f in ?? ()
#15 0x0804f03a in ?? ()
#16 0xf7d92637 in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6
#17 0x0804f139 in ?? ()

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


Re: [sqlite] Bug: WINDOW clause within a CTE

2019-09-15 Thread Dan Kennedy


On 15/9/62 11:57, Jake Thaw wrote:

The following examples demonstrate a possible bug when using a WINDOW
clause within a CTE:

SQLite version 3.30.0 2019-09-14 16:44:51
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE x AS SELECT 1 a UNION SELECT 2;
sqlite>
sqlite> -- Unexpected result - expect 1,1
sqlite> WITH y AS (
...> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a))
...> SELECT * FROM y;
1
2
sqlite> -- Unexpected result - expected "Error: no such column: fake_column"
sqlite> WITH y AS (
...> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION
BY fake_column))
...> SELECT * FROM y;
1
2



Thanks for tracking down and reporting these. Now fixed here:

  https://sqlite.org/src/info/ca564d4b5b19fe56


sqlite> -- Possible unexpected result - expected "Error: no such
column: fake_column"
sqlite> SELECT 1 WINDOW win AS (PARTITION BY fake_column);
1


I think we'll leave this one as is. SQLite only resolves the references 
in the WINDOW clause if it is used, so this doesn't produce an error. 
There are few other scenarios SQLite does this too. The statement 
"SELECT (0 AND fake_column);", for example.


Dan.



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


[sqlite] Bug: WINDOW clause within a CTE

2019-09-14 Thread Jake Thaw
The following examples demonstrate a possible bug when using a WINDOW
clause within a CTE:

SQLite version 3.30.0 2019-09-14 16:44:51
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE x AS SELECT 1 a UNION SELECT 2;
sqlite>
sqlite> -- Unexpected result - expect 1,1
sqlite> WITH y AS (
   ...> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a))
   ...> SELECT * FROM y;
1
2
sqlite> -- Unexpected result - expected "Error: no such column: fake_column"
sqlite> WITH y AS (
   ...> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION
BY fake_column))
   ...> SELECT * FROM y;
1
2
sqlite> -- Possible unexpected result - expected "Error: no such
column: fake_column"
sqlite> SELECT 1 WINDOW win AS (PARTITION BY fake_column);
1
sqlite> -- Expected result
sqlite> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a);
1
1
sqlite> -- Expected result
sqlite> WITH y AS (SELECT Row_Number() OVER (PARTITION BY a) FROM x)
   ...> SELECT * FROM y;
1
1
sqlite> -- Expected result
sqlite> SELECT * FROM (
   ...> SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a));
1
1
sqlite>


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


[sqlite] Bug with json_group_array() as a window function

2019-09-06 Thread Shawn Wagner
Using 3.29 and a 3.30 snapshot:

When using json_group_array() as a window function, it loses the tagging of
its argument as being JSON, treating JSON objects etc. as strings instead
when creating arrays.

Sample table:

CREATE TABLE testjson(id INTEGER PRIMARY KEY, j TEXT);
INSERT INTO testjson VALUES(1, '{"a":1}');
INSERT INTO testjson VALUES(2, '{"b":2}');

This query

SELECT json_group_array(json(j)) OVER (ORDER BY id) FROM testjson;

produces

["{\"a\":1}"]
["{\"a\":1}","{\"b\":2}"]

instead of

[{"a":1}]
[{"a":1},{"b":2}]

while the plain aggregate

SELECT json_group_array(json(j)) FROM testjson;

produces the expected

[{"a":1},{"b":2}]
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug in checkin e2c6fed8f8 vtab.c sqlite3_drop_modules with SQLITE_ENABLE_API_ARMOR: zName is undeclared

2019-08-19 Thread Keith Medcalf

SQLITE_API int sqlite3_drop_modules(sqlite3 *db, const char** azNames){
  HashElem *pThis, *pNext;
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
#endif
  for(pThis=sqliteHashFirst(>aModule); pThis; pThis=pNext){
Module *pMod = (Module*)sqliteHashData(pThis);
pNext = sqliteHashNext(pThis);
if( azNames ){
  int ii;
  for(ii=0; azNames[ii]!=0 && strcmp(azNames[ii],pMod->zName)!=0; ii++){}
  if( azNames[ii]!=0 ) continue;
}
createModule(db, pMod->zName, 0, 0, 0);
  }
  return SQLITE_OK;
}


-- 
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


[sqlite] bug: typo in sqlite3.n

2019-08-19 Thread Roland Illig
From sqlite-autoconf-329:

tea/doc/sqlite3.n says "SQLite3 is a self-contains". It should be
"contained" instead.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug report: DROP TABLE while a cursor is open leads to SQLITE_LOCKED

2019-08-19 Thread Jürgen Baier

Hi,

sorry for the repost. I just noticed that I probably should have added 
"Bug report" in the subject line.


I'm using the Xerial JDBC driver for accessing SQLite (but this issue is 
not directly related to the driver).


I have the problem that it is not possible to drop a table in the same
database connection while a resultset is open:

0. Preparation: Create table t1 and add some values

1. Open connection
2. Create temporary table tmp1
3. Execute SELECT statement on t1 (SELECT * FROM t1).
4. Execute DROP TABLE tmp1 while still iterating over the result of 3.

=> [SQLITE_LOCKED]  A table in the database is locked (database table is
locked)

Note that all this happens in a single thread.

Someone of the Xerial community pointed me to

https://www2.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked

It seems while a resultset is open it also was not possible in earlier
SQLite versions to CREATE a table, but this restriction has been fixed
in the meantime.

Is it planned to fix this for DROP TABLE too? Or is there some workaround?

Thanks,

Jürgen





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


Re: [sqlite] Bug: LSM1 lsm1BestIndex() always chooses table scan

2019-08-17 Thread Richard Hipp
On 8/16/19, James Kafader  wrote:
>
> We think, after trying out a fix that line 845 of lsm_vtab.c contains a
> bug. This line
>   for(i=0; inConstraint && idxNum<16; i++, pConstraint++){
> should perhaps be replaced by this line:
>for(i=0; inConstraint && idxNum>16; i++, pConstraint++){
>

Thanks for debugging this.  We think the actual fix is:

   for(i=0; inConstraint; i++, pConstraint++){

In other words, take out the idxNum term completely.  I'm not sure
what that was about - probably some cruft left over from whatever
virtual table I used as a template when throwing together the LSM1
vtab.

The fix has now been checked into the SQLite source tree.
-- 
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


[sqlite] Bug: LSM1 lsm1BestIndex() always chooses table scan

2019-08-16 Thread James Kafader
Hi SQLite devs,

I'd like to begin with a "thank you" for a great tool that we use every day
at Internet Archive.

We are currently considering SQLite's LSM engine (we are aware it is not
considered production quality) to implement a index server process that
will underpin the Wayback Machine's URL replay.

We would like to use SQLite with the LSM1 module loaded to be able to write
efficient SQL to look up key ranges; we currently use a mechanism very
similar to this (but slower and more unweildy!) to serve this large index
out of plain text files.

In building the LSM1 module I followed charles leifer's instructions here:
https://www.charlesleifer.com/blog/lsm-key-value-storage-in-sqlite3/

resulting in this approximate set of commands:
wget http://sqlite.org/src/tarball/version-3.29.0/sqlite-3.29.tar.gz
tar zxvf sqlite-3.29.tar.gz
cd sqlite/ext/lsm1
CFLAGS="-g -fPIC" TCCX="gcc -g -fPIC" make lsm.so

we then load the lsm module that compiles into a version-compatible SQLite
3:
sqlite3
sqlite> .load /var/tmp/sqlite/ext/lsm1/lsm
sqlite> .timer on
sqlite> create virtual table cdx using lsm1 ('/var/tmp/cdx.lsm', key, TEXT,
value);
# here we load some data from a CSV file, appx 3m records for testing
purposes
# then we query out the last record from the loaded data
sqlite> select key, value from cdx where key =
'151,65,166,108)/media/newmuseum/images/0/51927_ca_object_representations_media_1_medium.jpg
20121001214108';
# this operation takes about 2s (!) and raised our curiosity. After a lot
of testing, it became clear that it's doing a full table scan, despite the
fact that the LSM implementation should be able to seek to this key.

We think, after trying out a fix that line 845 of lsm_vtab.c contains a
bug. This line
  for(i=0; inConstraint && idxNum<16; i++, pConstraint++){
should perhaps be replaced by this line:
   for(i=0; inConstraint && idxNum>16; i++, pConstraint++){

whether or not that's the correct fix, it seems to be something close to
logic involving idxNum there; it might be that it should be set to 0 to
begin with rather than 99.

Thanks again! We will report any other bugs we uncover.

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


[sqlite] Bug report: documentation for the SQLite Android bindings should clearly call out their poor query performance

2019-07-18 Thread Edward Pastuszenski
I apologize in advance if this is the wrong place to report bugs with the 
SQLite Android bindings, but I couldn’t figure out how to file a ticket on that 
subsite (https://sqlite.org/android/) and didn’t see any contact information 
there, so I figured I’d try here.

Query performance, particularly for large result sets, is significantly worse 
(by up to an order of magnitude) when using the SQLite Android bindings than 
with AOSP SQLite, even for completely identical data. This slowness originates 
from the bindings’ nativeExecuteForCursorWindow implementation, which uses JNI 
in a loop because the much faster C++ methods the AOSP uses are private. This 
is responsible for the entire performance difference.
I understand that this is the only way for the bindings to manipulate 
CursorWindows from C++, but this is too big a downside to be mentioned only in 
code comments (https://www.sqlite.org/android/artifact/afd8e719c44fb86f), and 
obliquely at that. It’s a systematic scalability issue and should be called out 
clearly, in the “Differences From the Built-in SQLite Support” section here 
(https://www.sqlite.org/android/doc/trunk/www/usage.wiki) or even on the 
bindings’ home page, given the severity of the difference.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report: crash when close blob handle after close_v2 db

2019-07-15 Thread Dan Kennedy


On 14/7/62 17:18, Chaoji Li wrote:

This problem is only present for 3.28+. A sample test case is attached.


Thanks for reporting this. We think it's fixed here:

  https://sqlite.org/src/info/52f463d29407fad6

The mailing list stripped off your test case, so if you could either run 
it with the latest SQLite from fossil or else post it inline here so 
that we can run it, that would be very helpful.


Thanks,

Dan.





Basically, the flow is:

1. Open  in-memory db A (we don't do anything about it).
2. Open db B  from file test.db
3. Create a blob handle from B
4. close_v2 A
5. close_v2 B
6. close blob handle -> Segmentation fault

The problem seems to go away if A is not created.
___
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] Bug when creating a table via select?

2019-07-15 Thread Dominique Devienne
On Mon, Jul 15, 2019 at 6:01 AM J. King  wrote:

> On July 14, 2019 11:56:15 p.m. EDT, Donald Shepherd <
> donald.sheph...@gmail.com> wrote:
> >sqlite> create table x(a int, b text, c real, d blob, e vartext,
> fgarbage);
> >sqlite> pragma table_info(x);
> >0|a|int|0||0
> >1|b|text|0||0
> >2|c|real|0||0
> >3|d|blob|0||0
> >4|e|vartext|0||0
> >5|f|garbage|0||0
> >sqlite> create table y as select * from x;
> >sqlite> pragma table_info(y);
> >0|a|INT|0||0
> >1|b|TEXT|0||0
> >2|c|REAL|0||0
> >3|d||0||0
> >4|e|TEXT|0||0
> >5|f|NUM|0||0
>
> Blobs have no affinity. The result you're seeing is correct, just
> represented in a surprising way.
>

Still. The fact garbage is mapped to NUM, and BLOB to nothing, is at the
very least "surprising",
despite being "correct" as per SQLite's "flexible typing" as DRH puts it.
Definitely worthy of the "new"
quirks.html page though IMHO. --DD
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug when creating a table via select?

2019-07-14 Thread J. King
On July 15, 2019 12:01:00 a.m. EDT, "J. King"  wrote:
>On July 14, 2019 11:56:15 p.m. EDT, Donald Shepherd
> wrote:
>>Somewhat bizarrely only "BLOB" affinity doesn't make it from the
>>original
>>table to the new table when using the "select" syntax to create the
>new
>>table.  Even items with aliased affinities (VARTEXT, or something that
>>defaults to NUMERIC) comes across as the base affinity but at least
>>have an
>>affinity.
>>
>>This is simple to reproduce:
>>
>>sqlite> .version
>>SQLite 3.29.0 2019-07-10 17:32:03
>>fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6
>>zlib version 1.2.11
>>gcc-5.2.0
>>sqlite> create table x(a int, b text, c real, d blob, e vartext, f
>>garbage);
>>sqlite> pragma table_info(x);
>>0|a|int|0||0
>>1|b|text|0||0
>>2|c|real|0||0
>>3|d|blob|0||0
>>4|e|vartext|0||0
>>5|f|garbage|0||0
>>sqlite> create table y as select * from x;
>>sqlite> pragma table_info(y);
>>0|a|INT|0||0
>>1|b|TEXT|0||0
>>2|c|REAL|0||0
>>3|d||0||0
>>4|e|TEXT|0||0
>>5|f|NUM|0||0
>>sqlite> select * from sqlite_master;
>>table|x|x|2|CREATE TABLE x(a int, b text, c real, d blob, e vartext, f
>>garbage)
>>table|y|y|3|CREATE TABLE y(
>>  a INT,
>>  b TEXT,
>>  c REAL,
>>  d,
>>  e TEXT,
>>  f NUM
>>)
>>___
>>sqlite-users mailing list
>>sqlite-users@mailinglists.sqlite.org
>>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>Blobs have no affinity. The result you're seeing is correct, just
>represented in a surprising way. 
>-- 
>J. King
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

I misspoke. Blobs have an affinity historically called NONE (which is distinct 
from no affinity, but that's not relevant here). Presumably SQLite represents 
the BLOB affinity as null as a means of saying "NONE", again for historical 
reasons. 
-- 
J. King
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug when creating a table via select?

2019-07-14 Thread J. King
On July 14, 2019 11:56:15 p.m. EDT, Donald Shepherd  
wrote:
>Somewhat bizarrely only "BLOB" affinity doesn't make it from the
>original
>table to the new table when using the "select" syntax to create the new
>table.  Even items with aliased affinities (VARTEXT, or something that
>defaults to NUMERIC) comes across as the base affinity but at least
>have an
>affinity.
>
>This is simple to reproduce:
>
>sqlite> .version
>SQLite 3.29.0 2019-07-10 17:32:03
>fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6
>zlib version 1.2.11
>gcc-5.2.0
>sqlite> create table x(a int, b text, c real, d blob, e vartext, f
>garbage);
>sqlite> pragma table_info(x);
>0|a|int|0||0
>1|b|text|0||0
>2|c|real|0||0
>3|d|blob|0||0
>4|e|vartext|0||0
>5|f|garbage|0||0
>sqlite> create table y as select * from x;
>sqlite> pragma table_info(y);
>0|a|INT|0||0
>1|b|TEXT|0||0
>2|c|REAL|0||0
>3|d||0||0
>4|e|TEXT|0||0
>5|f|NUM|0||0
>sqlite> select * from sqlite_master;
>table|x|x|2|CREATE TABLE x(a int, b text, c real, d blob, e vartext, f
>garbage)
>table|y|y|3|CREATE TABLE y(
>  a INT,
>  b TEXT,
>  c REAL,
>  d,
>  e TEXT,
>  f NUM
>)
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Blobs have no affinity. The result you're seeing is correct, just represented 
in a surprising way. 
-- 
J. King
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug when creating a table via select?

2019-07-14 Thread Donald Shepherd
Somewhat bizarrely only "BLOB" affinity doesn't make it from the original
table to the new table when using the "select" syntax to create the new
table.  Even items with aliased affinities (VARTEXT, or something that
defaults to NUMERIC) comes across as the base affinity but at least have an
affinity.

This is simple to reproduce:

sqlite> .version
SQLite 3.29.0 2019-07-10 17:32:03
fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6
zlib version 1.2.11
gcc-5.2.0
sqlite> create table x(a int, b text, c real, d blob, e vartext, f garbage);
sqlite> pragma table_info(x);
0|a|int|0||0
1|b|text|0||0
2|c|real|0||0
3|d|blob|0||0
4|e|vartext|0||0
5|f|garbage|0||0
sqlite> create table y as select * from x;
sqlite> pragma table_info(y);
0|a|INT|0||0
1|b|TEXT|0||0
2|c|REAL|0||0
3|d||0||0
4|e|TEXT|0||0
5|f|NUM|0||0
sqlite> select * from sqlite_master;
table|x|x|2|CREATE TABLE x(a int, b text, c real, d blob, e vartext, f
garbage)
table|y|y|3|CREATE TABLE y(
  a INT,
  b TEXT,
  c REAL,
  d,
  e TEXT,
  f NUM
)
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug report: crash when close blob handle after close_v2 db

2019-07-14 Thread Simon Slavin
On 14 Jul 2019, at 11:18am, Chaoji Li  wrote:

> This problem is only present for 3.28+. A sample test case is attached.

Thank you for identifying this behaviour.  I'm sure the development team will 
reply to your post.

Attachments are automatically ignored by the mailing list.  You can include 
your code in your message, or post it on a server and include a pointer.  
However, in this case you have included a good clear description of how to 
reproduce the problem and this should not be necessary.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bug report: crash when close blob handle after close_v2 db

2019-07-14 Thread Chaoji Li
This problem is only present for 3.28+. A sample test case is attached.

Basically, the flow is:

1. Open  in-memory db A (we don't do anything about it).
2. Open db B  from file test.db
3. Create a blob handle from B
4. close_v2 A
5. close_v2 B
6. close blob handle -> Segmentation fault

The problem seems to go away if A is not created.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug in all-bnf.html documentation?

2019-07-13 Thread George King
Fantastic, thank you!


> On Jul 13, 2019, at 1:48 PM, Richard Hipp  wrote:
> 
> On 7/13/19, George King  wrote:
>> Is there any written description of the Sqlite grammar or is it
>> now only described by the images? If nothing else, I'd be interested to peek
>> at any sort of grammar representation in the source code.
> 
> The images are the definitive description of the language.
> 
> The implementation is described by a LALR(1) grammar at
> https://sqlite.org/src/file/src/parse.y if that is of any help to you.
> -- 
> 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] Bug in all-bnf.html documentation?

2019-07-13 Thread Richard Hipp
On 7/13/19, George King  wrote:
> Is there any written description of the Sqlite grammar or is it
> now only described by the images? If nothing else, I'd be interested to peek
> at any sort of grammar representation in the source code.

The images are the definitive description of the language.

The implementation is described by a LALR(1) grammar at
https://sqlite.org/src/file/src/parse.y if that is of any help to you.
-- 
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] Bug in all-bnf.html documentation?

2019-07-13 Thread George King
Thank you. Is there any written description of the Sqlite grammar or is it now 
only described by the images? If nothing else, I'd be interested to peek at any 
sort of grammar representation in the source code.


> On Jul 13, 2019, at 12:28 PM, Richard Hipp  wrote:
> 
> On 7/13/19, George King  wrote:
>> I found
>> the all-bnf.html page after a quick google search.
> 
> That file is obsolete cruft in the Fossil repository that hosts the
> SQLite documentation.  The BNF representation has not been supported
> for years.  Shane added that support for us
> almost 10 years ago, but the generator script has not been keep
> up-to-date and no longer
> functions.
> 
> The file has been removed from the trunk check-in and should no longer
> appear when you attempt to load it.
> 
> -- 
> 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

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


Re: [sqlite] Bug in all-bnf.html documentation?

2019-07-13 Thread Richard Hipp
On 7/13/19, George King  wrote:
> I found
> the all-bnf.html page after a quick google search.

That file is obsolete cruft in the Fossil repository that hosts the
SQLite documentation.  The BNF representation has not been supported
for years.  Shane added that support for us
almost 10 years ago, but the generator script has not been keep
up-to-date and no longer
functions.

The file has been removed from the trunk check-in and should no longer
appear when you attempt to load it.

-- 
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


[sqlite] Bug in all-bnf.html documentation?

2019-07-13 Thread George King
Hello,

I'm writing to report an apparent error in the Sqlite documentation. I found 
the all-bnf.html page after a quick google search.

https://www.sqlite.org/docsrc/doc/trunk/art/syntax/all-bnf.html 


It appears that the page is truncated; "sql-stmt-list" and "sql-stmt" appear 
fine, but nothing appears after "alter-table-stmt:". Perhaps this is generated 
and the output is truncated?

 Please let me 
know if I should send this report somewhere else.

Thank you,
George

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


Re: [sqlite] Bug in sqlite3.c

2019-06-06 Thread bhandari_nikhil
I tried "INSERT INTO ft(ft) VALUES('integrity-check')" and it also did not
give any error. But the rebuild command helped solve my problem as the
crashes stopped, otherwise my application was crashing at every commit
operation (thanks a lot for that).

Is there any command/API which can bypass FTS5 when the db itself has been
instructed to use the FTS5 extension ?



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug in sqlite3.c

2019-06-04 Thread Dan Kennedy


On 4/6/62 12:11, bhandari_nikhil wrote:

Thanks Dan. I had checked the database integrity using the following command:

sqlite3 myfile.db "PRAGMA integrity_check;"



Try "INSERT INTO ft(ft) VALUES('integrity-check')", where "ft" is the 
name of the fts5 table.



And it had reported ok. I will see if I can share the database file here.
Can you let me know how to check the db file (in case I am not able to share
the db file here) ? And how the fts5 can get corrupted ?


The easiest explanation is that the fts5 tables were modified directly, 
bypassing fts5. Or there could be a bug in fts5 - a bug that may or may not 
still be present; there have been fixes since 3.14. A memory related bug in the 
application could also cause this.
 


To run the rebuild command, the ft refers to the db name ?


The fts5 table name.

Dan.



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


Re: [sqlite] Bug in sqlite3.c

2019-06-03 Thread bhandari_nikhil
Thanks Dan. I had checked the database integrity using the following command:

sqlite3 myfile.db "PRAGMA integrity_check;"

And it had reported ok. I will see if I can share the database file here.
Can you let me know how to check the db file (in case I am not able to share
the db file here) ? And how the fts5 can get corrupted ?

To run the rebuild command, the ft refers to the db name ?

BTW, I just looked at the code, not used the latest version.



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug in sqlite3.c

2019-06-03 Thread Dan Kennedy


On 3/6/62 12:51, bhandari_nikhil wrote:

  I am facing a crash in sqlite3fts5BufferAppendBlob. Following is the
backtrace:

#0  sqlite3Fts5BufferAppendBlob (pRc=pRc@entry=0xf54139c8,
pBuf=pBuf@entry=0xf5afeb90, nData=4294967295, pData=0xf49fff76 "90246ture")
at sqlite3.c:180474

#1  0xf717b6f8 in fts5WriteAppendTerm (p=p@entry=0xf54139a8,
pWriter=pWriter@entry=0xf5afeb84, nTerm=5, pTerm=0xf49fff70
"06280290246ture") at sqlite3.c:188868

#2  0xf717bf29 in fts5IndexMergeLevel (p=p@entry=0xf54139a8,
ppStruct=ppStruct@entry=0xf5afec3c, iLvl=3, pnRem=0xf5afec38) at
sqlite3.c:189176

There is an apparent bug in sqlite3fts5BufferAppendBlob where it is
asserting for check on nData < 0 but nData is actually u32. The nData should
be int, not u32. I am using version 3.14.0.100 but the bug is present in the
latest version as well.

Also, if you notice in frame #0, the nData passed is 0x which is -1.
It was calculated to be -1 in frame #1 where it did nTerm - nPrefix. The
nPrefix value came out to be 6 and nTerm was 5. I want to know when this
nPrefix becomes > nTerm ?


Thanks for reporting this.

I think that can only happen if the FTS5 records stored in the database 
are corrupt. If you are able to share the database I can check for you. 
You can probably repair the index using the following:


  https://sqlite.org/fts5.html#the_rebuild_command

Also, I would have thought this crash would have been fixed by this 
change, which is in 3.28.0:


  https://sqlite.org/src/info/673a7dd698

Have you demonstrated the crash with the latest version, or just 
eyeballed the code?


Cheers then,

Dan.







Regards
Nikhil Bhandari



--
Sent from: http://sqlite.1065341.n5.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


[sqlite] Bug in sqlite3.c

2019-06-02 Thread bhandari_nikhil
 I am facing a crash in sqlite3fts5BufferAppendBlob. Following is the
backtrace: 

#0  sqlite3Fts5BufferAppendBlob (pRc=pRc@entry=0xf54139c8,
pBuf=pBuf@entry=0xf5afeb90, nData=4294967295, pData=0xf49fff76 "90246ture")
at sqlite3.c:180474 

#1  0xf717b6f8 in fts5WriteAppendTerm (p=p@entry=0xf54139a8,
pWriter=pWriter@entry=0xf5afeb84, nTerm=5, pTerm=0xf49fff70
"06280290246ture") at sqlite3.c:188868 

#2  0xf717bf29 in fts5IndexMergeLevel (p=p@entry=0xf54139a8,
ppStruct=ppStruct@entry=0xf5afec3c, iLvl=3, pnRem=0xf5afec38) at
sqlite3.c:189176 

There is an apparent bug in sqlite3fts5BufferAppendBlob where it is
asserting for check on nData < 0 but nData is actually u32. The nData should
be int, not u32. I am using version 3.14.0.100 but the bug is present in the
latest version as well.

Also, if you notice in frame #0, the nData passed is 0x which is -1.
It was calculated to be -1 in frame #1 where it did nTerm - nPrefix. The
nPrefix value came out to be 6 and nTerm was 5. I want to know when this
nPrefix becomes > nTerm ? 

Regards 
Nikhil Bhandari 



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Bug in sqlite: "View with UNION ALL and limit in subquery" (v 3.28.0)

2019-05-29 Thread Richard Hipp
Thank you for the report.  The problem is now fixed on trunk.

Ticket: https://www.sqlite.org/src/info/c41afac34f15781f
Fix: https://www.sqlite.org/src/info/523b42371122d9e1

On 5/29/19, Marco Foit  wrote:
> Dear SQLite Developers,
>
> I just noticed the following bug in SQLite version 3.28.0:
>
> 
>
> create table t AS values (1), (2);
>
> .print "select with correct output  ..."
> select * from ( select * from t limit 1 )
> union all
> select * from t
> ;
>
> .print "same select leads to incorrect result when used inside view ..."
> create view v as
> select * from ( select * from t limit 1 )
> union all
> select * from t
> ;
>
> select * from v;
>
> 
>
>
> * How to reproduce:
> Run the attached SQL code from a shell with:
>
>   sqlite3 < sqlite-bug.sql
>
>
> * Expected result:
> Both queries should yield the following output:
> 1
> 1
> 2
>
> * What did go wrong:
> The second query yields to the output:
> 1
>
>
> It seems that the limit clause in the compound select when used inside a
> view is used for the overall result set and not for the subquery.
>
>
> In the hope that this might help others.
> Thank you very much for your hard work!
>
>
> Cheers,
> Marco
>
>
> ___
> 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


[sqlite] Bug in sqlite: "View with UNION ALL and limit in subquery" (v 3.28.0)

2019-05-29 Thread Marco Foit

Dear SQLite Developers,

I just noticed the following bug in SQLite version 3.28.0:



create table t AS values (1), (2);

.print "select with correct output  ..."
select * from ( select * from t limit 1 )
union all
select * from t
;

.print "same select leads to incorrect result when used inside view ..."
create view v as
select * from ( select * from t limit 1 )
union all
select * from t
;

select * from v;




* How to reproduce:
Run the attached SQL code from a shell with:

sqlite3 < sqlite-bug.sql


* Expected result:
Both queries should yield the following output:
1
1
2

* What did go wrong:
The second query yields to the output:
1


It seems that the limit clause in the compound select when used inside a 
view is used for the overall result set and not for the subquery.



In the hope that this might help others.
Thank you very much for your hard work!


Cheers,
Marco


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


Re: [sqlite] bug in sqlite3??

2019-05-28 Thread Stephen Chrzanowski
 Let's not forget that the size of the database is going to grow above and
beyond the "number of rows" due to pages that aren't reserved for your
data, such index pages, etc.

On Tue, May 28, 2019 at 1:49 PM Jens Alfke  wrote:

>
>
> > On May 26, 2019, at 7:21 PM, John Brigham  wrote:
> >
> > The size of the file reflects the number of rows that should be
> present.  And furthermore, the size of the file nicely reflects the number
> of days. […]  Trust me when I say that this file is way to big for the
> number of rows.
>
> SQLite files can contain free space after rows are deleted. (The free
> space will eventually be reused for new data, or it can be reclaimed using
> the VACUUM pragma.) So the size of the file does not necessarily reflect
> the amount of data it currently contains.
>
> Try opening a copy of the database with the `sqlite3` CLI tool and
> entering “PRAGMA vacuum;”. Then exit and look at the file size.
>
> —Jens
> ___
> 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] bug in sqlite3??

2019-05-28 Thread Simon Slavin
On 28 May 2019, at 6:49pm, Jens Alfke  wrote:

> Try opening a copy of the database with the `sqlite3` CLI tool and entering 
> “PRAGMA vacuum;”. Then exit and look at the file size.

Alternatively use the sqlite3_analyze tool and read the "Pages on the freelist" 
figures.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


  1   2   3   4   5   6   7   8   9   10   >