当前位置: 首页 > news >正文

编译SQLite 3.51源码并体验新功能

11月4日,SQLite 3.51发布了,第一时间下载体验,Linux上预编译的只有AMD64版本,而且依赖高版本C动态库,不方便使用,所以按编译说明,手工编译。

我下载的是 amalgamation版本,解压缩后只有4个文件,

root@6ae32a5ffcde:/par/sqlite351# ls -l
total 10912
-rwxrwxrwx 1 root root 1068027 Nov  5 12:18 shell.c
-rwxrwxrwx 1 root root 9385376 Nov  5 12:18 sqlite3.c
-rwxrwxrwx 1 root root  671792 Nov  5 12:18 sqlite3.h
-rwxrwxrwx 1 root root   38632 Nov  5 12:18 sqlite3ext.hroot@6ae32a5ffcde:/par/sqlite351# gcc -Os -I. -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS4 \-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 \-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS \-DHAVE_READLINE \shell.c sqlite3.c -ldl -lm -lreadline -lncurses -o sqlite351 -O3

编译过程有一些警告,但没有错误,生成了sqlite351 文件。发版说明写到,

root@6ae32a5ffcde:/par/sqlite351# ls
shell.c  sqlite351  sqlite3.c  sqlite3.h  sqlite351  sqlite3ext.h
root@6ae32a5ffcde:/par/sqlite351# ./sqlite351
SQLite version 3.51.0 2025-11-04 19:38:17
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .mode box
sqlite> select 1 a, '中文' b;
┌───┬──────┐
│ a │  b   │
├───┼──────┤
│ 1 │ 中文 │
└───┴──────┘

作为对比,再次编译了上一个版本3.50.4版源码,旧版本的源码到github镜像获取,结果如下:


root@6ae32a5ffcde:/par/sqlite3504# ./sqlite3504
SQLite version 3.50.4 2025-07-30 19:33:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .mode box
sqlite> select 1 a, '中文' b;
┌───┬────┐
│ a │ b  │
├───┼────┤
│ 1 │ 中 │
└───┴────┘
sqlite>

这么明显的问题,不知为何到现在才解决,也许用SQLite作为前台的少,大部分都是在后台调用。
2.对于当前时间戳的支持

sqlite> create table test as select now()ts;
Parse error: no such function: nowcreate table test as select now()ts;error here ---^
sqlite> create table test as select current_timestamp() ts;
Parse error: near "(": syntax errorcreate table test as select current_timestamp() ts;error here ---^
sqlite> create table test as select current_timestamp ts;
sqlite> select * from test;
┌─────────────────────┐
│         ts          │
├─────────────────────┤
│ 2025-11-05 13:06:28 │
└─────────────────────┘

只能用不带括号的current_timestamp来查询。
3. .timer计时精确到毫秒

sqlite> select sum(value) from generate_series(1,100000);
┌────────────┐
│ sum(value) │
├────────────┤
│ 5000050000 │
└────────────┘
Run Time: real 0.004330 user 0.004000 sys 0.000000-- 再试一个高难度数独
WITH RECURSIVEinput(sud) AS (VALUES('.....1..7....6..2.8..9..3...954....3..3...4..4......8......7..6.1..2....5..3..9..')),digits(z, lp) AS (VALUES('1', 1)UNION ALL SELECTCAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9),x(s, ind) AS (SELECT sud, instr(sud, '.') FROM inputUNION ALLSELECTsubstr(s, 1, ind-1) || z || substr(s, ind+1),instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )FROM x, digits AS zWHERE ind>0AND NOT EXISTS (SELECT 1FROM digits AS lpWHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)OR z.z = substr(s, ((ind-1)%9) + (lp-1)*9 + 1, 1)OR z.z = substr(s, (((ind-1)/3) % 3) * 3+ ((ind-1)/27) * 27 + lp+ ((lp-1) / 3) * 6, 1)))
SELECT s FROM x WHERE ind=0;
┌──────────────────────────────────────────────────────────────┐
│                              s                               │
├──────────────────────────────────────────────────────────────┤
│ 346251897759863124821974365195486273683712459472539681238197 │
│ 546914625738567348912                                        │
└──────────────────────────────────────────────────────────────┘
Run Time: real 10.579288 user 10.548000 sys 0.032000--旧版
sqlite> select sum(value) from generate_series(1,100000);
┌────────────┐
│ sum(value) │
├────────────┤
│ 5000050000 │
└────────────┘
Run Time: real 0.003 user 0.004000 sys 0.000000
http://www.dtcms.com/a/577089.html

相关文章:

  • CMP(类Cloudera CDP 7.3 404版华为泰山Kunpeng)和Apache Doris的对比
  • 水果电商网站建设相关文献163企业邮箱登入口
  • HarmonyOS黑马云音乐项目增加网络听歌功能(一、轮播图的实现)
  • 二、Netty-NIO核心原理详解(NIO核心组件:Buffer、Channel、Selector)
  • 网站短信接口怎么做网站开发环境有什么
  • 网站建设客户开发方案网站建设公司介绍
  • 矩阵乘法优化
  • sward零基础学习,如何在sward文档中集成Kanass事项
  • React使用笔记(持续更新中)
  • ArkTS运行时
  • C语言递归宏详解
  • 指令微调(Instruction Tuning)
  • Linux 中 NIC(网络接口卡)和协议栈的区别以及DPDK
  • MATLAB实现贝叶斯回归预测
  • ZYNQ介绍
  • 【Python】-- 趣味代码 - Piano游戏
  • 解决使用EasyExcel导出带公式的excel,公式不自动计算问题
  • 展示型网站多少钱建设大型网站的公司
  • 前端FAQ: 描述⼀下你最近使⽤过的前端框架,并解释为何选择它们?
  • [特殊字符] 微前端部署实战:Nginx 配置 HTTPS 与 CORS 跨域解决方案(示例版)
  • 短视频矩阵系统搭建指南:源码部署与全流程解析
  • 李沐动手学深度学习笔记(1)
  • 做网站云服务器选择多大带宽北京网站建设有哪些公司好
  • 第8章 模块系统
  • GraphRAG在Windows环境下离线部署
  • Spring Boot 实战:企业级接口限流与熔断机制设计
  • 二十一、二进制文件部署高可用集群
  • 窗口dp|组合数学
  • 【linux国庆练习】
  • 织梦cms怎么做双语网站wordpress网页小特效