mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 23:55:57 -05:00
Load our SQLite extension
This commit is contained in:
parent
517f11c691
commit
da0011de3b
@ -34,7 +34,7 @@ ANTLR_SOURCES = \
|
||||
ANTLR_PRODUCTS =
|
||||
|
||||
forked_daapd_CPPFLAGS = -D_GNU_SOURCE @ZLIB_CFLAGS@ @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @FFMPEG_CFLAGS@ @CONFUSE_CFLAGS@ @TAGLIB_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ @LIBGCRYPT_CFLAGS@ @ALSA_CFLAGS@ @OSS4CPPFLAGS@ \
|
||||
-DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" -DSTATEDIR="\"$(localstatedir)\""
|
||||
-DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" -DSTATEDIR="\"$(localstatedir)\"" -DPKGLIBDIR="\"$(pkglibdir)\""
|
||||
|
||||
forked_daapd_LDADD = @ZLIB_LIBS@ @AVAHI_LIBS@ @SQLITE3_LIBS@ @FFMPEG_LIBS@ @CONFUSE_LIBS@ @FLAC_LIBS@ @TAGLIB_LIBS@ @LIBEVENT_LIBS@ @LIBAVL_LIBS@ @MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@ @LIBGCRYPT_LIBS@ @ALSA_LIBS@ @LIBUNISTRING@
|
||||
forked_daapd_SOURCES = main.c \
|
||||
|
25
src/db.c
25
src/db.c
@ -3757,6 +3757,7 @@ db_daap_unicode_xcollation(void *notused, int llen, const void *left, int rlen,
|
||||
int
|
||||
db_perthread_init(void)
|
||||
{
|
||||
char *errmsg;
|
||||
int ret;
|
||||
|
||||
ret = sqlite3_open(db_path, &hdl);
|
||||
@ -3768,19 +3769,35 @@ db_perthread_init(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = sqlite3_create_function(hdl, "daap_songalbumid", 2, SQLITE_UTF8, NULL, db_daap_songalbumid_xfunc, NULL, NULL);
|
||||
ret = sqlite3_enable_load_extension(hdl, 1);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not create daap_songalbumid function: %s\n", sqlite3_errmsg(hdl));
|
||||
DPRINTF(E_LOG, L_DB, "Could not enable extension loading\n");
|
||||
|
||||
sqlite3_close(hdl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = sqlite3_create_collation(hdl, "DAAP", SQLITE_UTF8, NULL, db_daap_unicode_xcollation);
|
||||
errmsg = NULL;
|
||||
ret = sqlite3_load_extension(hdl, PKGLIBDIR "/forked-daapd-sqlext.so", NULL, &errmsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not create sqlite3 custom collation DAAP: %s\n", sqlite3_errmsg(hdl));
|
||||
if (errmsg)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not load SQLite extension: %s\n", errmsg);
|
||||
sqlite3_free(errmsg);
|
||||
}
|
||||
else
|
||||
DPRINTF(E_LOG, L_DB, "Could not load SQLite extension: %s\n", sqlite3_errmsg(hdl));
|
||||
|
||||
sqlite3_close(hdl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = sqlite3_enable_load_extension(hdl, 0);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not disable extension loading\n");
|
||||
|
||||
sqlite3_close(hdl);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user