Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:10:00+00:00 2026-05-27T08:10:00+00:00

I try to enable foreign keys using HDBC-sqlite3 haskell library. This library uses a

  • 0

I try to enable foreign keys using HDBC-sqlite3 haskell library. This library uses a little helper c – function

int sqlite3_open2(const char *filename, finalizeonce **ppo)

which calls in turn sqlite3_open one.
In the sqlite documentation I’ve found nice sqlite3_db_config function which is supposed to enable foreign keys. To test it I’ve added quickly 2 lines into sqlite3_open2 (the two last ones of the listing):

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);  

  ...

My surprise was the result: Foreign Keys: ON/OFF:0 ERR:1.

Could somebody give me a hint what am I doing wrong or what would be the proper way of enabling foreign keys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:10:00+00:00Added an answer on May 27, 2026 at 8:10 am

    According to the docs:

    Assuming the library is compiled with foreign key constraints enabled,
    it must still be enabled by the application at runtime, using the
    PRAGMA foreign_keys command. For example:

    sqlite> PRAGMA foreign_keys = ON;

    Foreign key constraints are disabled by default (for backwards
    compatibility), so must be enabled separately for each database
    connection separately.

    So, after your sqlite3_open(), you probably want to add the following:

    sqlite3_exec(ppDb, "PRAGMA foreign_keys = ON;", 0, 0, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try running this in a .VBS file MsgBox(545.14-544.94) You get a neat little answer
I try to enable msvc memory leak detection with line number like this snippet
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
try it out: volatile float bob = -344.0f; unsigned int fred = (unsigned int)bob;
I recently decided to try emacs for java development, so this is the first
I try to use the following technique in order to enable/disable the shadow effect
I try to enable a brwoserback button for my tabs. But the problem is
I logged into my PC with administrator account. When I try to enable the
I try to modify the metabase of IIS6, I've cheched the checkbox to enable
I'll try to better explain my problem. Using Eclipse and MTJ (Mobile Tools for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.