#include "system.h"
#include <rpmlib.h>
#include <rpmmacro.h>
#include <rpmurl.h>
#include <rpmdb.h>
#include "sqlite3.h"
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | _sql_db_s |
struct | _sql_dbcursor_s |
union | _dbswap |
Defines | |
#define | _DBSWAP(_a) |
Typedefs | |
typedef _sql_db_s | SQL_DB |
typedef _sql_dbcursor_s * | SCP_t |
Functions | |
static void | enterChroot (dbiIndex dbi) |
static void | leaveChroot (dbiIndex dbi) |
static void | dbg_scp (void *ptr) |
static void | dbg_keyval (const char *msg, dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags) |
static SCP_t | scpResetKeys (SCP_t scp) |
static SCP_t | scpResetAv (SCP_t scp) |
static SCP_t | scpReset (SCP_t scp) |
static SCP_t | scpFree (SCP_t scp) |
static SCP_t | scpNew (DB *dbp) |
static int | sql_step (dbiIndex dbi, SCP_t scp) |
static int | sql_bind_key (dbiIndex dbi, SCP_t scp, int pos, DBT *key) |
static int | sql_bind_data (dbiIndex dbi, SCP_t scp, int pos, DBT *data) |
static int | sql_startTransaction (dbiIndex dbi) |
static int | sql_endTransaction (dbiIndex dbi) |
static int | sql_commitTransaction (dbiIndex dbi, int flag) |
static int | sql_busy_handler (void *dbi_void, int time) |
static int | sql_initDB (dbiIndex dbi) |
Verify the DB is setup. | |
static int | sql_cclose (dbiIndex dbi, DBC *dbcursor, unsigned int flags) |
Close database cursor. | |
static int | sql_close (dbiIndex dbi, unsigned int flags) |
Close index database, and destroy database handle. | |
static int | sql_open (rpmdb rpmdb, rpmTag rpmtag, dbiIndex *dbip) |
Return handle for an index database. | |
static int | sql_sync (dbiIndex dbi, unsigned int flags) |
Flush pending operations to disk. | |
static int | sql_copen (dbiIndex dbi, DB_TXN *txnid, DBC **dbcp, unsigned int flags) |
Open database cursor. | |
static int | sql_cdel (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags) |
Delete (key,data) pair(s) using db->del or dbcursor->c_del. | |
static int | sql_cget (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags) |
Retrieve (key,data) pair using db->get or dbcursor->c_get. | |
static int | sql_cput (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, unsigned int flags) |
Store (key,data) pair using db->put or dbcursor->c_put. | |
static int | sql_byteswapped (dbiIndex dbi) |
Is database byte swapped? | |
static int | sql_associate (dbiIndex dbi, dbiIndex dbisecondary, int(*callback)(DB *, const DBT *, const DBT *, DBT *), unsigned int flags) |
Associate secondary database with primary. | |
static int | sql_join (dbiIndex dbi, DBC **curslist, DBC **dbcp, unsigned int flags) |
Return join cursor for list of cursors. | |
static int | sql_cdup (dbiIndex dbi, DBC *dbcursor, DBC **dbcp, unsigned int flags) |
Duplicate a database cursor. | |
static int | sql_cpget (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *pkey, DBT *data, unsigned int flags) |
Retrieve (key,data) pair using dbcursor->c_pget. | |
static int | sql_ccount (dbiIndex dbi, DBC *dbcursor, unsigned int *countp, unsigned int flags) |
Retrieve count of (possible) duplicate items using dbcursor->c_count. | |
static int | sql_stat (dbiIndex dbi, unsigned int flags) |
Save statistics in database handle. | |
Variables | |
static int | _debug = 0 |
static unsigned int | endian = 0x11223344 |
static char * | sqlCwd = NULL |
static int | sqlInRoot = 0 |
_dbiVec | sqlitevec |
|
Value: { unsigned char _b, *_c = (_a).uc; \ _b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \ _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \ } |
|
|
|
|
|
Definition at line 172 of file sqlite.c. References _debug, __db_dbt::data, dbg_scp(), _dbiIndex::dbi_rpmtag, _dbiIndex::dbi_subfile, RPMTAG_NAME, and __db_dbt::size. Referenced by sql_cdel(), sql_cget(), and sql_cput(). |
|
Definition at line 162 of file sqlite.c. References _debug, _sql_dbcursor_s::ac, _sql_dbcursor_s::all, _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, _sql_dbcursor_s::nalloc, _sql_dbcursor_s::nc, _sql_dbcursor_s::nr, and _sql_dbcursor_s::rx. Referenced by dbg_keyval(), scpReset(), scpResetAv(), and scpResetKeys(). |
|
Definition at line 114 of file sqlite.c. References _debug, rpmdb_s::db_chrootDone, _dbiIndex::dbi_root, _dbiIndex::dbi_rpmdb, errno, sqlCwd, sqlInRoot, and xrealloc(). Referenced by sql_byteswapped(), sql_cclose(), sql_cdel(), sql_cget(), sql_close(), sql_copen(), sql_cput(), sql_open(), sql_stat(), and sql_sync(). |
|
Definition at line 143 of file sqlite.c. References _debug, _free(), rpmdb_s::db_chrootDone, _dbiIndex::dbi_root, _dbiIndex::dbi_rpmdb, sqlCwd, and sqlInRoot. Referenced by sql_byteswapped(), sql_cclose(), sql_cdel(), sql_cget(), sql_close(), sql_copen(), sql_cput(), sql_open(), sql_stat(), and sql_sync(). |
|
Definition at line 280 of file sqlite.c. References _debug, _free(), _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, scpReset(), and scpResetKeys(). Referenced by sql_byteswapped(), sql_cclose(), sql_cdel(), sql_cput(), sql_initDB(), and sql_stat(). |
|
Definition at line 294 of file sqlite.c. References _debug, and xcalloc(). Referenced by sql_byteswapped(), sql_cdel(), sql_copen(), sql_cput(), sql_initDB(), and sql_stat(). |
|
Definition at line 252 of file sqlite.c. References _debug, _sql_dbcursor_s::cmd, dbg_scp(), _sql_dbcursor_s::pStmt, RPMMESS_WARNING, rpmMessage, _sql_dbcursor_s::rx, and scpResetAv(). Referenced by scpFree(), and sql_cget(). |
|
Definition at line 215 of file sqlite.c. References _debug, _free(), _sql_dbcursor_s::ac, _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, dbg_scp(), _sql_dbcursor_s::nalloc, _sql_dbcursor_s::nc, and _sql_dbcursor_s::nr. Referenced by scpReset(), and sql_cget(). |
|
Definition at line 195 of file sqlite.c. References _debug, _free(), __db_dbt::data, dbg_scp(), _sql_dbcursor_s::keys, and _sql_dbcursor_s::nkeys. Referenced by scpFree(), and sql_cget(). |
|
Associate secondary database with primary.
Definition at line 1315 of file sqlite.c. References _debug. |
|
Definition at line 539 of file sqlite.c. References __db_dbt::data, _sql_dbcursor_s::pStmt, and __db_dbt::size. Referenced by sql_cdel(), and sql_cput(). |
|
Definition at line 470 of file sqlite.c. References _DBSWAP, __db_dbt::data, _dbiIndex::dbi_rpmtag, dbiByteSwapped(), _sql_dbcursor_s::pStmt, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPMDBI_PACKAGES, __db_dbt::size, tagType(), and _dbswap::ui. Referenced by sql_cdel(), sql_cget(), and sql_cput(). |
|
Definition at line 624 of file sqlite.c. References _, _dbiIndex::dbi_file, RPMMESS_WARNING, and rpmMessage. Referenced by sql_open(). |
|
Is database byte swapped?
Definition at line 1260 of file sqlite.c. References _sql_dbcursor_s::av, _sql_db_s::db, _dbiIndex::dbi_db, endian, enterChroot(), leaveChroot(), _sql_dbcursor_s::nc, _sql_dbcursor_s::nr, _sql_dbcursor_s::pzErrmsg, RPMMESS_DEBUG, RPMMESS_WARNING, rpmMessage, scpFree(), scpNew(), and _dbswap::uc. |
|
Close database cursor.
Definition at line 737 of file sqlite.c. References _debug, _free(), DB_WRITECURSOR, enterChroot(), _sql_dbcursor_s::ldata, leaveChroot(), _sql_dbcursor_s::lkey, scpFree(), sql_commitTransaction(), and sql_endTransaction(). Referenced by sql_copen(). |
|
Retrieve count of (possible) duplicate items using dbcursor->c_count.
Definition at line 1389 of file sqlite.c. References _debug. |
|
Delete (key,data) pair(s) using db->del or dbcursor->c_del.
Definition at line 998 of file sqlite.c. References _sql_dbcursor_s::cmd, _sql_db_s::db, dbg_keyval(), _dbiIndex::dbi_db, _dbiIndex::dbi_subfile, enterChroot(), leaveChroot(), _sql_dbcursor_s::pStmt, _sql_dbcursor_s::pzErrmsg, RPMMESS_WARNING, rpmMessage, scpFree(), scpNew(), sql_bind_data(), sql_bind_key(), and sql_step(). |
|
Duplicate a database cursor.
Definition at line 1351 of file sqlite.c. References _debug. |
|
Retrieve (key,data) pair using db->get or dbcursor->c_get.
Definition at line 1039 of file sqlite.c. References _debug, _free(), _sql_dbcursor_s::all, _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, _sql_dbcursor_s::cmd, __db_dbt::data, _sql_db_s::db, DB_DBT_MALLOC, DB_NOTFOUND, DB_SET, dbg_keyval(), _dbiIndex::dbi_db, _dbiIndex::dbi_rpmtag, _dbiIndex::dbi_subfile, enterChroot(), __db_dbt::flags, _sql_dbcursor_s::keys, _sql_dbcursor_s::ldata, leaveChroot(), _sql_dbcursor_s::lkey, _sql_dbcursor_s::nkeys, _sql_dbcursor_s::nr, _sql_dbcursor_s::pStmt, _sql_dbcursor_s::pzErrmsg, RPMDBI_PACKAGES, RPMMESS_WARNING, rpmMessage, _sql_dbcursor_s::rx, scpReset(), scpResetAv(), scpResetKeys(), __db_dbt::size, sql_bind_key(), sql_step(), _sql_dbcursor_s::used, xcalloc(), and xmalloc(). |
|
Close index database, and destroy database handle.
Definition at line 776 of file sqlite.c. References _, _free(), _sql_db_s::db, _dbiIndex::dbi_db, enterChroot(), leaveChroot(), RPMMESS_DEBUG, rpmMessage, and sql_commitTransaction(). Referenced by sql_open(). |
|
Definition at line 599 of file sqlite.c. References _debug, _sql_db_s::db, _dbiIndex::dbi_db, _dbiIndex::dbi_subfile, sql_startTransaction(), and _sql_db_s::transaction. Referenced by sql_cclose(), sql_close(), and sql_sync(). |
|
Open database cursor.
Definition at line 961 of file sqlite.c. References _debug, DB_WRITECURSOR, _dbiIndex::dbi_db, _dbiIndex::dbi_rpmtag, enterChroot(), leaveChroot(), scpNew(), sql_cclose(), sql_startTransaction(), tagName(), and tagType(). |
|
Retrieve (key,data) pair using dbcursor->c_pget.
Definition at line 1371 of file sqlite.c. References _debug. |
|
Store (key,data) pair using db->put or dbcursor->c_put.
Definition at line 1218 of file sqlite.c. References _sql_dbcursor_s::cmd, _sql_db_s::db, dbg_keyval(), _dbiIndex::dbi_db, _dbiIndex::dbi_rpmtag, _dbiIndex::dbi_subfile, enterChroot(), leaveChroot(), _sql_dbcursor_s::pStmt, _sql_dbcursor_s::pzErrmsg, RPMMESS_WARNING, rpmMessage, scpFree(), scpNew(), sql_bind_data(), sql_bind_key(), and sql_step(). |
|
Definition at line 577 of file sqlite.c. References _debug, _sql_db_s::db, _dbiIndex::dbi_db, _dbiIndex::dbi_subfile, and _sql_db_s::transaction. Referenced by sql_cclose(). |
|
Verify the DB is setup. . if not initialize it Create the table.. create the db_info Definition at line 646 of file sqlite.c. References _debug, _sql_dbcursor_s::av, _sql_db_s::db, _dbiIndex::dbi_db, _dbiIndex::dbi_no_fsync, _dbiIndex::dbi_rpmtag, _dbiIndex::dbi_subfile, endian, _sql_dbcursor_s::nc, _sql_dbcursor_s::nr, _sql_dbcursor_s::pzErrmsg, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPMDBI_PACKAGES, RPMMESS_WARNING, rpmMessage, scpFree(), scpNew(), tagName(), tagType(), and _dbswap::uc. Referenced by sql_open(). |
|
Return join cursor for list of cursors.
Definition at line 1333 of file sqlite.c. References _debug. |
|
Return handle for an index database.
Definition at line 812 of file sqlite.c. References _, _free(), db3New(), rpmdb_s::db_home, rpmdb_s::db_root, _dbiIndex::dbi_db, _dbiIndex::dbi_file, _dbiIndex::dbi_home, _dbiIndex::dbi_mode, _dbiIndex::dbi_root, _dbiIndex::dbi_rpmtag, _dbiIndex::dbi_subfile, _dbiIndex::dbi_vec, enterChroot(), leaveChroot(), rpmGenPath(), rpmioMkpath(), RPMMESS_DEBUG, rpmMessage, sql_busy_handler(), sql_close(), sql_initDB(), stpcpy(), tagName(), urlPath(), and xcalloc(). |
|
Definition at line 555 of file sqlite.c. References _debug, _sql_db_s::db, _dbiIndex::dbi_db, _dbiIndex::dbi_subfile, and _sql_db_s::transaction. Referenced by sql_commitTransaction(), and sql_copen(). |
|
Definition at line 310 of file sqlite.c. References _DBSWAP, _debug, _sql_dbcursor_s::ac, _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, _sql_dbcursor_s::cmd, _dbiIndex::dbi_db, dbiByteSwapped(), _sql_dbcursor_s::nalloc, _sql_dbcursor_s::nc, _sql_dbcursor_s::nr, _sql_dbcursor_s::pStmt, _dbswap::ui, xmalloc(), xrealloc(), and xstrdup(). Referenced by sql_cdel(), sql_cget(), and sql_cput(). |
|
Flush pending operations to disk.
Definition at line 940 of file sqlite.c. References enterChroot(), leaveChroot(), and sql_commitTransaction(). |
|
|
|
Definition at line 109 of file sqlite.c. Referenced by sql_byteswapped(), and sql_initDB(). |
|
Definition at line 111 of file sqlite.c. Referenced by enterChroot(), and leaveChroot(). |
|
Definition at line 112 of file sqlite.c. Referenced by enterChroot(), and leaveChroot(). |
|
Initial value: { 0, 0, 0, sql_open, sql_close, sql_sync, sql_associate, sql_join, sql_copen, sql_cclose, sql_cdup, sql_cdel, sql_cget, sql_cpget, sql_cput, sql_ccount, sql_byteswapped, sql_stat } |