src/xmms/sqlite.c File Reference

Sqlite Backend. More...

#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   36

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,...)
gboolean xmms_sqlite_query_int (sqlite3 *sql, gint32 *out, const gchar *query,...)
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 * tables []
const char * views []
const char * triggers []
const char * indices []
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_collidx_stm []

Detailed Description

Sqlite Backend.

Definition in file sqlite.c.


Define Documentation

#define DB_VERSION   36

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 102 of file sqlite.c.

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

Definition at line 103 of file sqlite.c.

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

Definition at line 104 of file sqlite.c.

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

Definition at line 105 of file sqlite.c.

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

Definition at line 106 of file sqlite.c.

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 126 of file sqlite.c.

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 121 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 112 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char* indices[]
Initial value:
 {
    
    "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 collectionlabels_idx ON CollectionLabels (collid)",

    NULL
}

Definition at line 89 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().

const char* tables[]

Definition at line 42 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char* triggers[]
Initial value:
 {
    NULL
}

Definition at line 85 of file sqlite.c.

Referenced by xmms_sqlite_create().

const char* views[]
Initial value:
 {
    NULL
}

Definition at line 81 of file sqlite.c.

Referenced by xmms_sqlite_create().


Generated on Tue Feb 23 18:14:36 2010 for XMMS2 by  doxygen 1.6.1