Re: [sqlite] Segmentation fault when using window function with (nested?) subquery

2018-12-06 Thread Richard Hipp
On 12/6/18, Larry Brasfield  wrote:
>
> The above fault and non-fault also occur on Windows 10 x64 (with a 64-bit
> build) with the SQLite3 v3.26 shell.  I can provide build options and
> compile flags if that would be useful.

Thanks, but I have no trouble reproducing the problem.  It is an issue
with the byte-code generator for window functions.  If you run with
assert()s enabled, it hits an assert() early on. This problem has
existed ever since window functions were added in version 3.25.0.  It
is not something new to 3.26.0.

-- 
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] Segmentation fault when using window function with (nested?) subquery

2018-12-06 Thread Larry Brasfield
Gene Sacky wrote:
> This query causes segmentation fault in SQLite 3.26.0 (on macOS 10.14.1).
> --
> SELECT * FROM(
> SELECT * FROM (SELECT 1 AS c) WHERE c IN (
> SELECT (row_number() OVER()) FROM (VALUES (0))
> )
> )
> --
> 
> However, no error occurs in the following queries. The only difference is
> whether it is wrapped with "SELECT * FROM" .
> --
> SELECT * FROM(
> SELECT 1 AS c WHERE c IN (
> SELECT (row_number() OVER()) FROM (VALUES (0))
> )
> )
> --
> 
> --
> SELECT * FROM (SELECT 1 AS c) WHERE c IN (
> SELECT (row_number() OVER()) FROM (VALUES (0))
> )
> --

The above fault and non-fault also occur on Windows 10 x64 (with a 64-bit 
build) with the SQLite3 v3.26 shell.  I can provide build options and compile 
flags if that would be useful.

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


[sqlite] Segmentation fault when using window function with (nested?) subquery

2018-12-06 Thread Gene Sacky
This query causes segmentation fault in SQLite 3.26.0 (on macOS 10.14.1).
--
SELECT * FROM(
SELECT * FROM (SELECT 1 AS c) WHERE c IN (
SELECT (row_number() OVER()) FROM (VALUES (0))
)
)
--

However, no error occurs in the following queries. The only difference is
whether it is wrapped with "SELECT * FROM" .
--
SELECT * FROM(
SELECT 1 AS c WHERE c IN (
SELECT (row_number() OVER()) FROM (VALUES (0))
)
)
--

--
SELECT * FROM (SELECT 1 AS c) WHERE c IN (
SELECT (row_number() OVER()) FROM (VALUES (0))
)
--


I found similar bug report about window function but I think it is unrelated
because it was fixed before 3.26.0.
http://sqlite.1065341.n5.nabble.com/Segmentation-Fault-When-Using-Window-Function-td104584.html






--
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] Segmentation Fault When Using Window Function

2018-11-09 Thread Jeremy Evans
On 11/09 09:26, Richard Hipp wrote:
> On 11/7/18, Jeremy Evans  wrote:
> > The following SQL causes a segmentation fault on:
> 
> Thank you for the bug report and reproducible test case.
> 
> The problem actually had nothing to do with window functions.  The use
> of window functions merely made the bug easier to hit.  The bug has
> gone undetected in the code for over three years.  It is now fixed on
> trunk.  If you can, please download and compile the latest trunk
> version and let us know whether or not it is working better for you.
> 
> If you do not want to download and compile from canonical sources, you can 
> patch
> your "sqlite3.c" source file by removing a single line of code:

I have tested this patch and confirmed that it fixes the issue.  Thank
you very much.

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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-09 Thread Simon Slavin
On 9 Nov 2018, at 3:35pm, Dennis Clarke  wrote:

> The list mail server sends this out about thirty times.

I saw just one copy, so I think the problem is nearer your end of the route.

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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-09 Thread Richard Hipp
On 11/9/18, Dennis Clarke  wrote:
> The list mail server sends this out about thirty times.  Not sure if
> anyone else sees abusive duplicates from the sqlite mail list server
> but I certainly do.

If you will send me headers to a few of this message by private email,
I will try to debug 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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-09 Thread Stephen Chrzanowski
I'm only seeing the one email, no duplicates.

On Fri, Nov 9, 2018 at 10:35 AM Dennis Clarke  wrote:

> On 11/08/2018 04:05 PM, Richard Hipp wrote:
> > In case you are not following the ticket at...
>
> 
>
> The list mail server sends this out about thirty times.  Not sure if
> anyone else sees abusive duplicates from the sqlite mail list server
> but I certainly do.
>
> Dennis
>
> ___
> 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] Segmentation Fault When Using Window Function

2018-11-09 Thread David Raymond
Commented out that 1 line from the amalgamation and can confirm that I'm no 
longer crashing on those queries.


-Original Message-
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Richard Hipp
Sent: Friday, November 09, 2018 9:26 AM
To: SQLite mailing list
Cc: c...@jeremyevans.net
Subject: Re: [sqlite] Segmentation Fault When Using Window Function

On 11/7/18, Jeremy Evans  wrote:
> The following SQL causes a segmentation fault on:

Thank you for the bug report and reproducible test case.

The problem actually had nothing to do with window functions.  The use
of window functions merely made the bug easier to hit.  The bug has
gone undetected in the code for over three years.  It is now fixed on
trunk.  If you can, please download and compile the latest trunk
version and let us know whether or not it is working better for you.

If you do not want to download and compile from canonical sources, you can patch
your "sqlite3.c" source file by removing a single line of code:

--- sqlite3.c-baseline
+++ sqlite3.c
@@ -139937,21 +139937,20 @@
   );
   sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
   sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
   if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
   if( pTabItem->fg.viaCoroutine ){
 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
 testcase( pParse->db->mallocFailed );
 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
   pTabItem->regResult, 1);
 sqlite3VdbeGoto(v, addrTop);
-pTabItem->fg.viaCoroutine = 0;  /* REMOVE THIS LINE OF CODE */
   }else{
 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
   }
   sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
   sqlite3VdbeJumpHere(v, addrTop);
   sqlite3ReleaseTempReg(pParse, regRecord);

   /* Jump here when skipping the initialization */
   sqlite3VdbeJumpHere(v, addrInit);
-- 
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] Segmentation Fault When Using Window Function

2018-11-09 Thread Dennis Clarke

On 11/08/2018 04:05 PM, Richard Hipp wrote:

In case you are not following the ticket at...




The list mail server sends this out about thirty times.  Not sure if 
anyone else sees abusive duplicates from the sqlite mail list server

but I certainly do.

Dennis

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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-09 Thread Richard Hipp
On 11/7/18, Jeremy Evans  wrote:
> The following SQL causes a segmentation fault on:

Thank you for the bug report and reproducible test case.

The problem actually had nothing to do with window functions.  The use
of window functions merely made the bug easier to hit.  The bug has
gone undetected in the code for over three years.  It is now fixed on
trunk.  If you can, please download and compile the latest trunk
version and let us know whether or not it is working better for you.

If you do not want to download and compile from canonical sources, you can patch
your "sqlite3.c" source file by removing a single line of code:

--- sqlite3.c-baseline
+++ sqlite3.c
@@ -139937,21 +139937,20 @@
   );
   sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
   sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
   if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
   if( pTabItem->fg.viaCoroutine ){
 sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
 testcase( pParse->db->mallocFailed );
 translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
   pTabItem->regResult, 1);
 sqlite3VdbeGoto(v, addrTop);
-pTabItem->fg.viaCoroutine = 0;  /* REMOVE THIS LINE OF CODE */
   }else{
 sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
   }
   sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
   sqlite3VdbeJumpHere(v, addrTop);
   sqlite3ReleaseTempReg(pParse, regRecord);

   /* Jump here when skipping the initialization */
   sqlite3VdbeJumpHere(v, addrInit);
-- 
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] Segmentation Fault When Using Window Function

2018-11-08 Thread Richard Hipp
On 11/8/18, J. King  wrote:
> On 2018-11-08 16:05:11, "Richard Hipp"  wrote:
>
>>In case you are not following the ticket at
>>https://www.sqlite.org/src/tktview/787fa716be3a7f650cac1b1413f12f95f5e7639d,
>>we have simplified the test case to the following:
>>
>
> Richard,
> My mail client appears to have exposed a bug in Fossil. In including the
> comma in its link-making of the URL (i.e.
> ),
> it brought me to a technically valid (response status 200) resource with
> an empty ticket metadata table save for a ticket UUID of "Deleted". As
> the ticket UUID is not deleted (it is invalid) I would have expected a
> 404 response with an appropriate message.

Thank you.  The obvious work-around here is to omit the common on the
end of the URL.  I'm going to continue focusing on the crash bug right
this moment

-- 
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] Segmentation Fault When Using Window Function

2018-11-08 Thread J. King

On 2018-11-08 16:05:11, "Richard Hipp"  wrote:


In case you are not following the ticket at
https://www.sqlite.org/src/tktview/787fa716be3a7f650cac1b1413f12f95f5e7639d,
we have simplified the test case to the following:



Richard,
My mail client appears to have exposed a bug in Fossil. In including the 
comma in its link-making of the URL (i.e. 
), 
it brought me to a technically valid (response status 200) resource with 
an empty ticket metadata table save for a ticket UUID of "Deleted". As 
the ticket UUID is not deleted (it is invalid) I would have expected a 
404 response with an appropriate message.


--
J. King

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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-08 Thread Richard Hipp
In case you are not following the ticket at
https://www.sqlite.org/src/tktview/787fa716be3a7f650cac1b1413f12f95f5e7639d,
we have simplified the test case to the following:

CREATE TABLE t5(a, b, c, d);
CREATE INDEX t5a ON t5(a);
CREATE INDEX t5b ON t5(b);
CREATE TABLE t6(e);
INSERT INTO t6 VALUES(1);
INSERT INTO t5 VALUES(1,1,1,1), (2,2,2,2);
SELECT * FROM t5 WHERE (a=1 OR b=2) AND c IN (
  SELECT e FROM (SELECT DISTINCT e FROM t6) WHERE e=1
);

The above fails going back to SQLite version 3.8.11 (2015-07-27).

On 11/7/18, Jeremy Evans  wrote:
> The following SQL causes a segmentation fault on:
>
> * OpenBSD -current (3.25.1 and 3.25.3)
> * MacOS 10.14 (3.25.2)
>
> No segmentation fault using the precompiled Windows binary, though.
>
> CREATE TABLE `artists` (
>   `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
>   `name` varchar(255)
> );
> CREATE TABLE `albums` (
>   `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
>   `name` varchar(255),
>   `artist_id` integer REFERENCES `artists`
> );
> INSERT INTO `artists` (`name`) VALUES ('Ar');
> INSERT INTO `albums` (`name`, `artist_id`) VALUES ('Al', 1);
> SELECT `artists`.*
> FROM `artists`
> INNER JOIN `artists` AS 'b' ON (`b`.`id` = `artists`.`id`)
> WHERE (`artists`.`id` IN (
>   SELECT `albums`.`artist_id`
>   FROM `albums`
>   WHERE ((`name` = 'Al')
> AND (`albums`.`artist_id` IS NOT NULL)
> AND (`albums`.`id` IN (
>   SELECT `id`
>   FROM (
> SELECT `albums`.`id`,
>row_number() OVER (
>  PARTITION BY `albums`.`artist_id`
>  ORDER BY `name`
>) AS 'x'
> FROM `albums`
> WHERE (`name` = 'Al')
>   ) AS 't1'
>   WHERE (`x` = 1)
> ))
> AND (`albums`.`id` IN (1, 2)))
> ));
>
> gdb output from OpenBSD-current:
>
> (gdb) bt
> #0  0x16ae6e4a888d in sqlite3VdbeExec (p=0x16ae5cb282c8) at
> sqlite3.c:87803
> #1  0x16ae6e46dd33 in sqlite3Step (p=0x16ae5cb282c8) at sqlite3.c:81043
> #2  0x16ae6e46d95a in sqlite3_step (pStmt=0x16ae5cb282c8) at
> sqlite3.c:81106
> #3  0x16abb6a3a6e6 in ?? () from /usr/local/bin/sqlite3
> #4  0x16abb6a20e6d in ?? () from /usr/local/bin/sqlite3
> #5  0x16abb6a3d0da in ?? () from /usr/local/bin/sqlite3
> #6  0x16abb6a21b6a in ?? () from /usr/local/bin/sqlite3
> #7  0x16abb6a17717 in ?? () from /usr/local/bin/sqlite3
> #8  0x16abb6a10056 in ?? () from /usr/local/bin/sqlite3
> #9  0x in ?? ()
> (gdb) info locals
> pC = (VdbeCursor *) 0x0
> pCrsr = (BtCursor *) 0x16ae5cb29ac8
> res = 1
> azType = 0x16ae6e5a8c00
> aLTb = 0x16ae6e422130 "\001"
> aEQb = 0x16ae6e422136 ""
> aGTb = 0x16ae6e42213c "\001"
> and_logic = 0x16ae6e422142 ""
> or_logic = 0x16ae6e42214b ""
> aFlag = 0x16ae6e422154
> aZero = 0x16ae6e5ac3e0 ""
> vfsFlags = 1054
> aOp = (Op *) 0x16ae54417008
> pOp = (Op *) 0x16ae54417ff8
> rc = 0
> db = (sqlite3 *) 0x16ae921ec408
> resetSchemaOnFault = 0 '\0'
> encoding = 1 '\001'
> iCompare = 1
> nVmStep = 291
> nProgressLimit = 4294967295
> aMem = (Mem *) 0x16ae544184b0
> pIn1 = (Mem *) 0x16ae54418600
> pIn2 = (Mem *) 0x16ae544187f8
> pIn3 = (Mem *) 0x16ae54418590
> pOut = (Mem *) 0x16ae54418a60
>
> If other gdb information would be helpful, please let me know.
>
> Thanks,
> Jeremy
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-08 Thread Olivier Mascia
Hello,

Without me knowing if it is related to your problem, I wonder what's the intent 
here?

> SELECT `artists`.*
> FROM `artists`
> INNER JOIN `artists` AS 'b' ON (`b`.`id` = `artists`.`id`)

-- 
Best Regards, Meilleures salutations, Met vriendelijke groeten,
Olivier Mascia


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


Re: [sqlite] Segmentation Fault When Using Window Function

2018-11-08 Thread David Raymond
This crashes both my self-compiled version of the CLI _and_ the pre-compiled 
one on Windows as well.
SQLite: 3.25.2
Windows 7


-Original Message-
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Jeremy Evans
Sent: Wednesday, November 07, 2018 7:36 PM
To: sqlite-users@mailinglists.sqlite.org
Subject: [sqlite] Segmentation Fault When Using Window Function

The following SQL causes a segmentation fault on:

* OpenBSD -current (3.25.1 and 3.25.3)
* MacOS 10.14 (3.25.2)

No segmentation fault using the precompiled Windows binary, though.

CREATE TABLE `artists` (
  `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  `name` varchar(255)
);
CREATE TABLE `albums` (
  `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  `name` varchar(255),
  `artist_id` integer REFERENCES `artists`
);
INSERT INTO `artists` (`name`) VALUES ('Ar');
INSERT INTO `albums` (`name`, `artist_id`) VALUES ('Al', 1);
SELECT `artists`.*
FROM `artists`
INNER JOIN `artists` AS 'b' ON (`b`.`id` = `artists`.`id`)
WHERE (`artists`.`id` IN (
  SELECT `albums`.`artist_id`
  FROM `albums`
  WHERE ((`name` = 'Al')
AND (`albums`.`artist_id` IS NOT NULL)
AND (`albums`.`id` IN (
  SELECT `id`
  FROM (
SELECT `albums`.`id`,
   row_number() OVER (
 PARTITION BY `albums`.`artist_id`
 ORDER BY `name`
   ) AS 'x'
FROM `albums`
WHERE (`name` = 'Al')
  ) AS 't1'
  WHERE (`x` = 1)
))
AND (`albums`.`id` IN (1, 2)))
));

gdb output from OpenBSD-current:

(gdb) bt
#0  0x16ae6e4a888d in sqlite3VdbeExec (p=0x16ae5cb282c8) at sqlite3.c:87803
#1  0x16ae6e46dd33 in sqlite3Step (p=0x16ae5cb282c8) at sqlite3.c:81043
#2  0x16ae6e46d95a in sqlite3_step (pStmt=0x16ae5cb282c8) at sqlite3.c:81106
#3  0x16abb6a3a6e6 in ?? () from /usr/local/bin/sqlite3
#4  0x16abb6a20e6d in ?? () from /usr/local/bin/sqlite3
#5  0x16abb6a3d0da in ?? () from /usr/local/bin/sqlite3
#6  0x16abb6a21b6a in ?? () from /usr/local/bin/sqlite3
#7  0x16abb6a17717 in ?? () from /usr/local/bin/sqlite3
#8  0x16abb6a10056 in ?? () from /usr/local/bin/sqlite3
#9  0x in ?? ()
(gdb) info locals
pC = (VdbeCursor *) 0x0
pCrsr = (BtCursor *) 0x16ae5cb29ac8
res = 1
azType = 0x16ae6e5a8c00
aLTb = 0x16ae6e422130 "\001"
aEQb = 0x16ae6e422136 ""
aGTb = 0x16ae6e42213c "\001"
and_logic = 0x16ae6e422142 ""
or_logic = 0x16ae6e42214b ""
aFlag = 0x16ae6e422154
aZero = 0x16ae6e5ac3e0 ""
vfsFlags = 1054
aOp = (Op *) 0x16ae54417008
pOp = (Op *) 0x16ae54417ff8
rc = 0
db = (sqlite3 *) 0x16ae921ec408
resetSchemaOnFault = 0 '\0'
encoding = 1 '\001'
iCompare = 1
nVmStep = 291
nProgressLimit = 4294967295
aMem = (Mem *) 0x16ae544184b0
pIn1 = (Mem *) 0x16ae54418600
pIn2 = (Mem *) 0x16ae544187f8
pIn3 = (Mem *) 0x16ae54418590
pOut = (Mem *) 0x16ae54418a60

If other gdb information would be helpful, please let me know.

Thanks,
Jeremy
___
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] Segmentation Fault When Using Window Function

2018-11-08 Thread Jeremy Evans
The following SQL causes a segmentation fault on:

* OpenBSD -current (3.25.1 and 3.25.3)
* MacOS 10.14 (3.25.2)

No segmentation fault using the precompiled Windows binary, though.

CREATE TABLE `artists` (
  `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  `name` varchar(255)
);
CREATE TABLE `albums` (
  `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  `name` varchar(255),
  `artist_id` integer REFERENCES `artists`
);
INSERT INTO `artists` (`name`) VALUES ('Ar');
INSERT INTO `albums` (`name`, `artist_id`) VALUES ('Al', 1);
SELECT `artists`.*
FROM `artists`
INNER JOIN `artists` AS 'b' ON (`b`.`id` = `artists`.`id`)
WHERE (`artists`.`id` IN (
  SELECT `albums`.`artist_id`
  FROM `albums`
  WHERE ((`name` = 'Al')
AND (`albums`.`artist_id` IS NOT NULL)
AND (`albums`.`id` IN (
  SELECT `id`
  FROM (
SELECT `albums`.`id`,
   row_number() OVER (
 PARTITION BY `albums`.`artist_id`
 ORDER BY `name`
   ) AS 'x'
FROM `albums`
WHERE (`name` = 'Al')
  ) AS 't1'
  WHERE (`x` = 1)
))
AND (`albums`.`id` IN (1, 2)))
));

gdb output from OpenBSD-current:

(gdb) bt
#0  0x16ae6e4a888d in sqlite3VdbeExec (p=0x16ae5cb282c8) at sqlite3.c:87803
#1  0x16ae6e46dd33 in sqlite3Step (p=0x16ae5cb282c8) at sqlite3.c:81043
#2  0x16ae6e46d95a in sqlite3_step (pStmt=0x16ae5cb282c8) at sqlite3.c:81106
#3  0x16abb6a3a6e6 in ?? () from /usr/local/bin/sqlite3
#4  0x16abb6a20e6d in ?? () from /usr/local/bin/sqlite3
#5  0x16abb6a3d0da in ?? () from /usr/local/bin/sqlite3
#6  0x16abb6a21b6a in ?? () from /usr/local/bin/sqlite3
#7  0x16abb6a17717 in ?? () from /usr/local/bin/sqlite3
#8  0x16abb6a10056 in ?? () from /usr/local/bin/sqlite3
#9  0x in ?? ()
(gdb) info locals
pC = (VdbeCursor *) 0x0
pCrsr = (BtCursor *) 0x16ae5cb29ac8
res = 1
azType = 0x16ae6e5a8c00
aLTb = 0x16ae6e422130 "\001"
aEQb = 0x16ae6e422136 ""
aGTb = 0x16ae6e42213c "\001"
and_logic = 0x16ae6e422142 ""
or_logic = 0x16ae6e42214b ""
aFlag = 0x16ae6e422154
aZero = 0x16ae6e5ac3e0 ""
vfsFlags = 1054
aOp = (Op *) 0x16ae54417008
pOp = (Op *) 0x16ae54417ff8
rc = 0
db = (sqlite3 *) 0x16ae921ec408
resetSchemaOnFault = 0 '\0'
encoding = 1 '\001'
iCompare = 1
nVmStep = 291
nProgressLimit = 4294967295
aMem = (Mem *) 0x16ae544184b0
pIn1 = (Mem *) 0x16ae54418600
pIn2 = (Mem *) 0x16ae544187f8
pIn3 = (Mem *) 0x16ae54418590
pOut = (Mem *) 0x16ae54418a60

If other gdb information would be helpful, please let me know.

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