【问题标题】:Rust Compilation dieselrs sqlite3 Generated-ColumsRust 编译柴油机 sqlite3 生成的列
【发布时间】:2021-09-26 13:31:24
【问题描述】:

背景

我需要在基于 arm 的计算机 (Jetson Nano) 中运行二进制文件,并且在我的团队决定使用 sqlite3 中的 Generated Columns 之前,我正在编译和运行它没有任何问题,这是在 3.31.0 版本中实现的功能但是该计算机运行的 Ubuntu 映像具有以前的开发版本,并使用 Dieselrs 库导致以下崩溃

thread 'main' panicked at 'called `Result::unwrap()` on an 
`Err` value: DatabaseError(__Unknown, "malformed database schema 
(group) - near \"as\": syntax error")', src/common_queries.rs:182:35

(我们处理解包,但我将其删除以查看真实信息)

我知道这是版本问题,因为显示的消息与 sqlite3 文档中所述的类似

.... If an earlier version of SQLite attempts to read a 
database file that contains a generated column in its schema, 
then that earlier version will perceive the generated column syntax 
as an error and will report that the database schema is corrupt. 

因为在 x86 计算机上使用 sqlite3 版本 3.34 可以正常工作。

尝试过什么

更新库

我已经尝试从官方网页下载 SQLite 3.36 版并运行sudo make install,但没有在/usr/include 中创建库,但不知何故它仍然编译它并且仍然显示相同的错误。 (也许它知道新库在哪里,但奇怪的是尽管它仍然不起作用)。

更改数据库模式

我能想出的最简单的解决方案是更改架构并将生成的列存储为一个新列,该列将使用after update trigger 生成,但这意味着数据库将不再处于正常形式.

交叉编译

由于它在 x86 机器上工作,我尝试针对该体系结构,采用不同的方法导致以下消息

linking with `aarch64-linux-gnu-ld` failed: exit status: 1

....
....
....

aarch64-linux-gnu-ld: cannot find -lsqlite3
aarch64-linux-gnu-ld: cannot find -lgcc_s


我猜这是因为它们都没有出现在 /usr/aarch64-linux-gnu/include/ 中,但安装 libsqlite3-dev 并不能解决问题。

关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: linux sqlite rust arm rust-diesel


    【解决方案1】:

    尝试将libsqlite3-sys = { version = "0.22.0", features = ["bundled"]} 添加到您的Cargo.toml。这会强制 libsqlite3 从源代码构建正确的目标。这使用了最新版本的 sqlite。 详情请参阅libsqlite3-sysdocumentation

    【讨论】:

    • 唉,我不得不回滚 git 来测试它,但它有效,谢谢,我的团队决定更改每个视图并动态生成列,因为我们无法修复它当时。我想我尝试了相同的导入,但版本不同。无论如何它似乎正在工作,但我还没有深入测试它
    猜你喜欢
    • 2020-11-07
    • 2021-07-25
    • 2021-03-10
    • 2022-01-21
    • 2022-12-10
    • 1970-01-01
    • 2021-12-31
    • 2022-01-03
    • 2022-12-10
    相关资源
    最近更新 更多