我尝试使用HDBC-sqlite3 haskell库启用外键.这个库使用了一个小辅助c函数
int sqlite3_open2(const char *filename, finalizeonce **ppo)
Run Code Online (Sandbox Code Playgroud)
它依次调用sqlite3_open.在sqlite文档中,我发现了一个很好的sqlite3_db_config函数,可以启用外键.为了测试它,我已经快速添加了2行sqlite3_open2(最后两个列表):
int sqlite3_open2(const char *filename, finalizeonce **ppo) {
sqlite3 *ppDb;
finalizeonce *newobj;
int res, *resFK, resFK1;
fprintf(stderr, "DB pointer: %d\n", ppDb);
res = sqlite3_open(filename, &ppDb);
resFK1 = sqlite3_db_config(ppDb, 1002, 1, resFK);
fprintf(stderr, "\nForeign Keys: ON/OFF:%d ERR:%d\n", resFK, resFK1);
...
Run Code Online (Sandbox Code Playgroud)
令我惊讶的是结果:Foreign Keys: ON/OFF:0 ERR:1.
有人能给我一个暗示我做错了什么或者什么是启用外键的正确方法?