SQLite generate_series missing

这一生的挚爱 提交于 2019-11-28 05:58:08

问题


I'm trying to work with the SQLite CLI, and I can't get the generate_series function to work. I can simulate it with the recursive CTE, as suggested in the documentation, but I can't seem to get any of the examples in that link to work. Here's some output from my session:

sqlite> with recursive generate_series(value) as (
    select 1
    union all select value+1
    from generate_series
    where value+1<=3)
select value from generate_series;
1
2
3
sqlite> select value from generate_series;
Error: no such table: generate_series
sqlite> select value from generate_series(1,3,1);
Error: no such table: generate_series

It seems like the ext/misc/series.c extension is not actually being statically linked. I also don't know how to do that if I compile from scratch. Am I doing something wrong here?

Edit Until how to compile an extension into SQLite has a good answer, I don't think I'll be able to do what I want. The documentation is wrong: the extension is not build into the command line shell by default.


回答1:


Download the extension: https://sqlite.org/src/file/ext/misc/series.c and compile it with:

gcc -g -O2 -shared -fPIC -o series ./series.c

After this the following should be working:

$ sqlite3
sqlite> .load ./series
sqlite> select value from generate_series(5,30,5);
5
10
15
20
25
30
sqlite> .exit


来源:https://stackoverflow.com/questions/52954732/sqlite-generate-series-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!