src/xmms/sqlite.c File Reference


Detailed Description

Sqlite Backend.

Definition in file sqlite.c.

#include <stdio.h>
#include <stdlib.h>
#include "xmms/xmms_config.h"
#include "xmms/xmms_log.h"
#include "xmmspriv/xmms_sqlite.h"
#include "xmmspriv/xmms_statfs.h"
#include "xmmspriv/xmms_utils.h"
#include "xmmspriv/xmms_collection.h"
#include "xmmsc/xmmsc_idnumbers.h"
#include <sqlite3.h>
#include <string.h>
#include <glib.h>

Go to the source code of this file.

Defines

#define DB_VERSION   35

Functions

gboolean xmms_sqlite_create (gboolean *create)
sqlite3 * xmms_sqlite_open ()
 Open a database or create a new one.
gboolean xmms_sqlite_exec (sqlite3 *sql, const char *query,...)
 A query that can't retrieve results.
gboolean xmms_sqlite_query_table (sqlite3 *sql, xmms_medialib_row_table_method_t method, gpointer udata, xmms_error_t *error, const gchar *query,...)
 Execute a query to the database.
gboolean xmms_sqlite_query_array (sqlite3 *sql, xmms_medialib_row_array_method_t method, gpointer udata, const gchar *query,...)
 Execute a query to the database.
void xmms_sqlite_close (sqlite3 *sql)
 Close database and free all resources used.
void xmms_sqlite_print_version (void)
gchar * sqlite_prepare_string (const gchar *input)

Variables

const char set_version_stm [] = "PRAGMA user_version=" XMMS_STRINGIFY (DB_VERSION)
const char create_Media_stm [] = "create table Media (id integer, key, value, source integer)"
const char create_Sources_stm [] = "create table Sources (id integer primary key AUTOINCREMENT, source)"
const char create_Playlist_stm [] = "create table Playlist (id primary key, name, pos integer)"
const char create_PlaylistEntries_stm [] = "create table PlaylistEntries (playlist_id int, entry, pos integer primary key AUTOINCREMENT)"
const char create_CollectionAttributes_stm [] = "create table CollectionAttributes (collid integer, key text, value text)"
const char create_CollectionConnections_stm [] = "create table CollectionConnections (from_id integer, to_id integer)"
const char create_CollectionIdlists_stm [] = "create table CollectionIdlists (collid integer, position integer, mid integer)"
const char create_CollectionLabels_stm [] = "create table CollectionLabels (collid integer, namespace integer, name text)"
const char create_CollectionOperators_stm [] = "create table CollectionOperators (id integer primary key AUTOINCREMENT, type integer)"
const char fill_stats []
 This magic numbers are taken from ANALYZE on a big database, if we change the db layout drasticly we need to redo them!
const char fill_init_playlist_stm []
const char create_idx_stm []
const char create_collidx_stm []


Define Documentation

#define DB_VERSION   35

Definition at line 37 of file sqlite.c.

Referenced by xmms_sqlite_create().


Variable Documentation

const char create_CollectionAttributes_stm[] = "create table CollectionAttributes (collid integer, key text, value text)"

Definition at line 44 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_CollectionConnections_stm[] = "create table CollectionConnections (from_id integer, to_id integer)"

Definition at line 45 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_CollectionIdlists_stm[] = "create table CollectionIdlists (collid integer, position integer, mid integer)"

Definition at line 46 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_CollectionLabels_stm[] = "create table CollectionLabels (collid integer, namespace integer, name text)"

Definition at line 47 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_CollectionOperators_stm[] = "create table CollectionOperators (id integer primary key AUTOINCREMENT, type integer)"

Definition at line 48 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_collidx_stm[]

Initial value:

 "create unique index collectionconnections_idx on CollectionConnections (from_id, to_id);"
                                  "create unique index collectionattributes_idx on CollectionAttributes (collid, key);"
                                  "create unique index collectionidlists_idx on CollectionIdlists (collid, position);"
                                  "create index collectionlabels_idx on CollectionLabels (collid);"

Definition at line 76 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_idx_stm[]

Initial value:

 "create unique index key_idx on Media (id,key,source);"
                              "CREATE INDEX id_key_value_1x ON Media (id, key, value COLLATE BINARY);"
                              "CREATE INDEX id_key_value_2x ON Media (id, key, value COLLATE NOCASE);"
                              "CREATE INDEX key_value_1x ON Media (key, value COLLATE BINARY);"
                              "CREATE INDEX key_value_2x ON Media (key, value COLLATE NOCASE);"
                              "create index playlistentries_idx on PlaylistEntries (playlist_id, entry);"
                              "create index playlist_idx on Playlist (name);"

Definition at line 68 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_Media_stm[] = "create table Media (id integer, key, value, source integer)"

Definition at line 40 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_Playlist_stm[] = "create table Playlist (id primary key, name, pos integer)"

Definition at line 42 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_PlaylistEntries_stm[] = "create table PlaylistEntries (playlist_id int, entry, pos integer primary key AUTOINCREMENT)"

Definition at line 43 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char create_Sources_stm[] = "create table Sources (id integer primary key AUTOINCREMENT, source)"

Definition at line 41 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char fill_init_playlist_stm[]

Initial value:

 "INSERT INTO CollectionOperators VALUES(1, %d);"
                                      "INSERT INTO CollectionLabels VALUES(1, %d, 'Default');"
                                      "INSERT INTO CollectionLabels VALUES(1, %d, '" XMMS_ACTIVE_PLAYLIST "');"
                                      "INSERT INTO CollectionIdlists VALUES(1, 1, 1);"

Definition at line 63 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char fill_stats[]

Initial value:

 "INSERT INTO sqlite_stat1 VALUES('Media', 'key_idx', '199568 14 1 1');"
                          "INSERT INTO sqlite_stat1 VALUES('Media', 'prop_idx', '199568 6653 3');"
                          "INSERT INTO sqlite_stat1 VALUES('PlaylistEntries', 'playlistentries_idx', '12784 12784 1');"
                          "INSERT INTO sqlite_stat1 VALUES('Playlist', 'playlist_idx', '2 1');"
                          "INSERT INTO sqlite_stat1 VALUES('Playlist', 'sqlite_autoindex_Playlist_1', '2 1');"
                          "INSERT INTO sqlite_stat1 VALUES('CollectionLabels', 'collectionlabels_idx', '2 2');"
                          "INSERT INTO sqlite_stat1 VALUES('CollectionIdlists', 'collectionidlists_idx', '15 15 1');"
                          "INSERT INTO sqlite_stat1 VALUES('CollectionAttributes', 'collectionattributes_idx', '2 2 1');"
This magic numbers are taken from ANALYZE on a big database, if we change the db layout drasticly we need to redo them!

Definition at line 54 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char set_version_stm[] = "PRAGMA user_version=" XMMS_STRINGIFY (DB_VERSION)

Definition at line 39 of file sqlite.c.

Referenced by xmms_sqlite_create().


Generated on Wed Dec 10 18:06:45 2008 for XMMS2 by  doxygen 1.5.6