SQLite Forum

Building SQLIte3 wiuth debug options fails on UBUNTU
Login
Which is correct. I should have issued a NEW in front of the variables.

However:
The missing NEW isn't detected when I build the database. I think that this is an error in the build function.

But it gets a little stranger when you execute this trigger with the  .selecttrace option. Notice that SQLite has detected that A1_STATUS is available at the start!

I get the impression that the 'sudden death' of the optimizer function that halts the execution.

Here is the result:
SQLite version 3.33.0 2020-06-24 11:45:35
Enter ".help" for usage hints.
sqlite> .selecttrace 0xffff
sqlite> update a1 set
   ...> a1_status = 2
   ...> where a1_index == 17;
1/0/563925A66748: begin processing:
'-- SELECT (1/563925A66748) selFlags=0x0 nSelectRow=0
    |-- result-set
    |   '-- op=177
    |-- FROM
    |   '-- {-1:*} main.sqlite_master
    '-- ORDERBY
        '-- ID "rowid"
1/0/563925A66748: after name resolution:
'-- SELECT (1/563925A66748) selFlags=0xc4 nSelectRow=0
    |-- result-set
    |   |-- AS type
    |   |   '-- {0:0} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS name
    |   |   '-- {0:1} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS tbl_name
    |   |   '-- {0:2} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS rootpage
    |   |   '-- {0:3} pTab=563925AC8BB8 fg.af=800000.n
    |   '-- AS sql
    |       '-- {0:4} pTab=563925AC8BB8 fg.af=800000.n
    |-- FROM
    |   '-- {0:*} main.sqlite_master tab='sqlite_master' nCol=5 ptr=563925AC8BB8 used=1f
    '-- ORDERBY
        '-- {0:-1} pTab=563925AC8BB8 fg.af=800000.D
1/0/563925A66748: generating column names
1/0/563925A66748: Constant propagation not helpful
1/0/563925A66748: After all FROM-clause analysis:
'-- SELECT (1/563925A66748) selFlags=0xc4 nSelectRow=0
    |-- result-set
    |   |-- AS type
    |   |   '-- {0:0} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS name
    |   |   '-- {0:1} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS tbl_name
    |   |   '-- {0:2} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS rootpage
    |   |   '-- {0:3} pTab=563925AC8BB8 fg.af=800000.n
    |   '-- AS sql
    |       '-- {0:4} pTab=563925AC8BB8 fg.af=800000.n
    |-- FROM
    |   '-- {0:*} main.sqlite_master tab='sqlite_master' nCol=5 ptr=563925AC8BB8 used=1f
    '-- ORDERBY
        '-- {0:-1} pTab=563925AC8BB8 fg.af=800000.D
1/0/563925A66748: WhereBegin
1/0/563925A66748: end processing
'-- SELECT (1/563925A66748) selFlags=0xc4 nSelectRow=200
    |-- result-set
    |   |-- AS type
    |   |   '-- {0:0} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS name
    |   |   '-- {0:1} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS tbl_name
    |   |   '-- {0:2} pTab=563925AC8BB8 fg.af=800000.n
    |   |-- AS rootpage
    |   |   '-- {0:3} pTab=563925AC8BB8 fg.af=800000.n
    |   '-- AS sql
    |       '-- {0:4} pTab=563925AC8BB8 fg.af=800000.n
    |-- FROM
    |   '-- {0:*} main.sqlite_master tab='sqlite_master' nCol=5 ptr=563925AC8BB8 used=1f
    '-- ORDERBY
        '-- {0:-1} pTab=563925AC8BB8 fg.af=800000.D
Error: no such column: A1_STATUS

SQLite suddenly kills the transaction while it tries to optimize the code.

I will add the NEW tomorrow and rerun the test. I am expecting that it will fail executing the condition.