MCPcopy Create free account
hub / github.com/SOUI2/soui / open_db

Function open_db

third-part/sqlite3/shell.c:4233–4253  ·  view source on GitHub ↗

** Make sure the database is open. If it is not, then open it. If ** the database fails to open, print an error message and exit. */

Source from the content-addressed store, hash-verified

4231** the database fails to open, print an error message and exit.
4232*/
4233static void open_db(ShellState *p, int keepAlive){
4234 if( p->db==0 ){
4235 sqlite3_initialize();
4236 sqlite3_open(p->zDbFilename, &p->db);
4237 globalDb = p->db;
4238 if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
4239 utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n",
4240 p->zDbFilename, sqlite3_errmsg(p->db));
4241 if( keepAlive ) return;
4242 exit(1);
4243 }
4244#ifndef SQLITE_OMIT_LOAD_EXTENSION
4245 sqlite3_enable_load_extension(p->db, 1);
4246#endif
4247 sqlite3_fileio_init(p->db, 0, 0);
4248 sqlite3_shathree_init(p->db, 0, 0);
4249 sqlite3_completion_init(p->db, 0, 0);
4250 sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
4251 shellAddSchemaName, 0, 0);
4252 }
4253}
4254
4255#if HAVE_READLINE || HAVE_EDITLINE
4256/*

Callers 4

shell_dbinfo_commandFunction · 0.85
do_meta_commandFunction · 0.85
runOneSqlLineFunction · 0.85
wmainFunction · 0.85

Calls 5

sqlite3_openFunction · 0.85
utf8_printfFunction · 0.85
sqlite3_completion_initFunction · 0.85
sqlite3_fileio_initFunction · 0.70
sqlite3_shathree_initFunction · 0.70

Tested by

no test coverage detected