[sqlite] COALESCE() ignores LIMIT 0 clause in subquery?

2019-09-23 Thread Justin Ng
Is this the appropriate place to discuss this? The below examples are expected to return 3. The first example returns 4, the second returns 3. It seems like LIMIT 0 is ignored by COALESCE(). https://www.db-fiddle.com/f/7YWZ5naLUfAHgNmh93Yo44/0 CREATE TABLE "myTable" ( "myColumn" INT PRIMARY

Re: [sqlite] COALESCE() does not short-circuit sometimes

2020-03-11 Thread Justin Ng
> Why do you think that that it should not evaluate ABS? It is there and you > asked for it. I believe it's a good idea to say, "hey, the amount you placed > here is out of boundary, think about what you are doing here." IMO, of > course. Thanks. > > josé Sometimes, when querying data,

[sqlite] Extracting metadata about generated columns with SQL only?

2020-03-11 Thread Justin Ng
SQLite 3.31 introduced generated columns. However, pragma table_xinfo() does not seem to give you the parenthesized expression of a generated column. Is there a version of "dflt_value" (in table_xinfo()) for generated columns? How would I access that? Also, does the "hidden" column (in

[sqlite] COALESCE() does not short-circuit sometimes

2020-03-11 Thread Justin Ng
This happens in SQLite 3.28 and 3.31. Consider the following queries, -- Query 1 SELECT COALESCE( NULL, (SELECT SUM(9223372036854775807) FROM (SELECT NULL UNION ALL SELECT NULL)) ); -- Query 2 SELECT COALESCE( (SELECT 'hello'), (SELECT SUM(9223372036854775807) FROM (SELECT

Re: [sqlite] COALESCE() does not short-circuit sometimes

2020-03-11 Thread Justin Ng
> It is not a "hack" because it does not work. It is what is called a "failed > attempt" at a hack. Yeah, the ABS() hack does not work. Which led me to use `(SELECT SUM(9223372036854775807) FROM (SELECT NULL UNION ALL SELECT NULL))` which **does** work. > However, your assessment that

Re: [sqlite] [EXTERNAL] Re: COALESCE() does not short-circuit sometimes

2020-03-11 Thread Justin Ng
> I have a patch to fix the problem on a branch > (https://www.sqlite.org/src/timeline?r=do-not-factor-functions) which > you can experiment with. More changes and analysis are needed prior to > landing on trunk. I cannot guarantee that such a landing will in fact > occur, though it seems more

Re: [sqlite] COALESCE() does not short-circuit sometimes

2020-03-11 Thread Justin Ng
> It is not a "hack" because it does not work. It is what is called a "failed > attempt" at a hack. Yeah, the ABS() hack does not work. Which led me to use `(SELECT SUM(9223372036854775807) FROM (SELECT NULL UNION ALL SELECT NULL))` which **does** work. > However, your assessment that

[sqlite] Cannot select specific columns from temp.sqlite_master unless temp.sqlite_master is aliased

2020-03-13 Thread Justin Ng
I just encountered something weird with "temp" and "sqlite_master". I was wondering if it was another bug, or intentional. - This throws a "column not found" error, SELECT sqlite_master.sql FROM temp.sqlite_master; - This throws a "column not found" error, SELECT