nalgeon / sqlean

The ultimate set of SQLite extensions
MIT License
3.76k stars 120 forks source link

define: segmentation fault when re-defining same name #141

Open mlawren opened 6 hours ago

mlawren commented 6 hours ago

Git HEAD: d3ea71ec5a (nalgeon/main)

The define extension has a little problem if you define something twice in the same session:

sqlite> .load dist/define
sqlite> .read test/define.sql
┌─────────────────────────────────────┐
│ define('sumn', '?1 * (?1 + 1) / 2') │
├─────────────────────────────────────┤
│ NULL                                │
└─────────────────────────────────────┘
┌──────┬─────────────┐
│ '01' │ sumn(0) = 0 │
├──────┼─────────────┤
│ 01   │ 1           │
└──────┴─────────────┘
┌──────┬─────────────┐
│ '02' │ sumn(1) = 1 │
├──────┼─────────────┤
│ 02   │ 1           │
└──────┴─────────────┘

....

┌──────┬────────────────────────────────┐
│ '86' │ eval('drop table tmp') is null │
├──────┼────────────────────────────────┤
│ 86   │ 1                              │
└──────┴────────────────────────────────┘
┌──────┬──────────────┐
│ '87' │ count(*) = 0 │
├──────┼──────────────┤
│ 87   │ 1            │
└──────┴──────────────┘
sqlite> .read test/define.sql
Runtime error near line 6: database is locked (5)
Segmentation fault

Test was on x86_64 Debian GNU/Linux.

mlawren commented 6 hours ago

Ah, I see further down in the test file that this is not entirely unknown..

-- redefine is not supported
-- select define('increment', '?1 + 1');

Regardless, I don't think crashing the process is quite the desired outcome.