|
rpm 5.3.7
|
#include "system.h"#include <rpmio.h>#include <rpmlog.h>#include <rpmmacro.h>#include <rpmurl.h>#include <rpmtag.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 | _RPMDB_INTERNAL |
| #define | UINT32_T rpmuint32_t |
| #define | _DBSWAP(_a) |
Typedefs | |
| typedef struct _sql_db_s | SQL_DB |
| typedef struct _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_exists (dbiIndex dbi, DBT *key, unsigned int flags) |
| Return whether key exists in a database. | |
| static int | sql_seqno (dbiIndex dbi, int64_t *seqnop, unsigned int flags) |
| Return next sequence number. | |
| 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_associate_foreign (dbiIndex dbi, dbiIndex dbisecondary, int(*callback)(DB *, const DBT *, DBT *, const DBT *, int *), 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 const char * | sqlCwd = NULL |
| static int | sqlInRoot = 0 |
| struct _dbiVec | sqlitevec |
| #define _DBSWAP | ( | _a | ) |
{ 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 120 of file sqlite.c.
Referenced by sql_bind_key(), and sql_step().
| #define UINT32_T rpmuint32_t |
Definition at line 54 of file sqlite.c.
Referenced by sql_cget().
| typedef struct _sql_dbcursor_s* SCP_t |
| static void dbg_keyval | ( | const char * | msg, |
| dbiIndex | dbi, | ||
| DBC * | dbcursor, | ||
| DBT * | key, | ||
| DBT * | data, | ||
| unsigned int | flags | ||
| ) | [static] |
Definition at line 207 of file sqlite.c.
References _debug, __db_dbt::data, dbg_scp(), and __db_dbt::size.
Referenced by sql_cdel(), sql_cget(), and sql_cput().
| static void dbg_scp | ( | void * | ptr | ) | [static] |
Definition at line 196 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().
| static void enterChroot | ( | dbiIndex | dbi | ) | [static] |
Definition at line 134 of file sqlite.c.
References _debug, Chdir(), Chroot(), 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().
| static void leaveChroot | ( | dbiIndex | dbi | ) | [static] |
Definition at line 169 of file sqlite.c.
References _debug, _free(), Chdir(), Chroot(), 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 321 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 335 of file sqlite.c.
References _debug, _sql_dbcursor_s::dbp, _sql_dbcursor_s::ldata, _sql_dbcursor_s::lkey, _sql_dbcursor_s::used, and xcalloc().
Referenced by sql_byteswapped(), sql_cdel(), sql_copen(), sql_cput(), sql_initDB(), and sql_stat().
Definition at line 293 of file sqlite.c.
References _debug, _sql_dbcursor_s::cmd, dbg_scp(), _sql_dbcursor_s::pStmt, rpmlog(), RPMLOG_WARNING, _sql_dbcursor_s::rx, and scpResetAv().
Referenced by scpFree(), and sql_cget().
Definition at line 254 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 232 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().
Definition at line 589 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 517 of file sqlite.c.
References _DBSWAP, __db_dbt::data, _sql_dbcursor_s::pStmt, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_MASK_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, RPM_UINT8_TYPE, RPMDBI_PACKAGES, __db_dbt::size, tagType(), and _dbswap::ui.
Referenced by sql_cdel(), sql_cget(), and sql_cput().
| static int sql_busy_handler | ( | void * | dbi_void, |
| int | time | ||
| ) | [static] |
Definition at line 677 of file sqlite.c.
References _, rpmlog(), and RPMLOG_WARNING.
Referenced by sql_open().
| static int sql_byteswapped | ( | dbiIndex | dbi | ) | [static] |
Is database byte swapped?
| dbi | index database handle |
Definition at line 1412 of file sqlite.c.
References D_, _sql_db_s::db, endian, enterChroot(), leaveChroot(), rpmlog(), RPMLOG_DEBUG, RPMLOG_WARNING, scpFree(), scpNew(), and _dbswap::uc.
Close database cursor.
| dbi | index database handle |
| dbcursor | database cursor |
| flags | (unused) |
Definition at line 823 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().
| static int sql_cdel | ( | dbiIndex | dbi, |
| DBC * | dbcursor, | ||
| DBT * | key, | ||
| DBT * | data, | ||
| unsigned int | flags | ||
| ) | [static] |
Delete (key,data) pair(s) using db->del or dbcursor->c_del.
| dbi | index database handle |
| dbcursor | database cursor (NULL will use db->del) |
| key | delete key value/length/flags |
| data | delete data value/length/flags |
| flags | (unused) |
Definition at line 1147 of file sqlite.c.
References _sql_db_s::db, dbg_keyval(), enterChroot(), leaveChroot(), rpmlog(), RPMLOG_WARNING, scpFree(), scpNew(), sql_bind_data(), sql_bind_key(), and sql_step().
| static int sql_cget | ( | dbiIndex | dbi, |
| DBC * | dbcursor, | ||
| DBT * | key, | ||
| DBT * | data, | ||
| unsigned int | flags | ||
| ) | [static] |
Retrieve (key,data) pair using db->get or dbcursor->c_get.
| dbi | index database handle |
| dbcursor | database cursor (NULL will use db->get) |
| key | retrieve key value/length/flags |
| data | retrieve data value/length/flags |
| flags | (unused) |
Definition at line 1188 of file sqlite.c.
References _debug, _free(), __db_dbt::data, _sql_db_s::db, DB_DBT_MALLOC, DB_NOTFOUND, DB_SET, dbg_keyval(), enterChroot(), __db_dbt::flags, leaveChroot(), RPMDBI_PACKAGES, rpmlog(), RPMLOG_WARNING, scpReset(), scpResetAv(), scpResetKeys(), __db_dbt::size, sql_bind_key(), sql_step(), UINT32_T, xcalloc(), and xmalloc().
| static int sql_close | ( | dbiIndex | dbi, |
| unsigned int | flags | ||
| ) | [static] |
Close index database, and destroy database handle.
| dbi | index database handle |
| flags | (unused) |
Definition at line 862 of file sqlite.c.
References _free(), D_, _sql_db_s::db, DB_PRIVATE, enterChroot(), leaveChroot(), rpmGenPath(), rpmlog(), RPMLOG_DEBUG, sql_commitTransaction(), Unlink(), and urlPath().
Referenced by sql_open().
| static int sql_commitTransaction | ( | dbiIndex | dbi, |
| int | flag | ||
| ) | [static] |
Definition at line 652 of file sqlite.c.
References _debug, _sql_db_s::db, sql_startTransaction(), and _sql_db_s::transaction.
Referenced by sql_cclose(), sql_close(), and sql_sync().
Open database cursor.
| dbi | index database handle |
| txnid | database transaction handle |
| dbcp | address of new database cursor |
| flags | DB_WRITECURSOR or 0 |
Definition at line 1109 of file sqlite.c.
References _debug, DB_WRITECURSOR, enterChroot(), leaveChroot(), RPM_MASK_TYPE, scpNew(), sql_cclose(), sql_startTransaction(), tagName(), and tagType().
| static int sql_cpget | ( | dbiIndex | dbi, |
| DBC * | dbcursor, | ||
| DBT * | key, | ||
| DBT * | pkey, | ||
| DBT * | data, | ||
| unsigned int | flags | ||
| ) | [static] |
Retrieve (key,data) pair using dbcursor->c_pget.
| dbi | index database handle |
| dbcursor | database cursor |
| key | secondary retrieve key value/length/flags |
| pkey | primary retrieve key value/length/flags |
| data | primary retrieve data value/length/flags |
| flags | DB_NEXT, DB_SET, or 0 |
Definition at line 1547 of file sqlite.c.
References _debug.
| static int sql_cput | ( | dbiIndex | dbi, |
| DBC * | dbcursor, | ||
| DBT * | key, | ||
| DBT * | data, | ||
| unsigned int | flags | ||
| ) | [static] |
Store (key,data) pair using db->put or dbcursor->c_put.
| dbi | index database handle |
| dbcursor | database cursor (NULL will use db->put) |
| key | store key value/length/flags |
| data | store data value/length/flags |
| flags | (unused) |
Definition at line 1370 of file sqlite.c.
References _sql_db_s::db, dbg_keyval(), enterChroot(), leaveChroot(), rpmlog(), RPMLOG_WARNING, scpFree(), scpNew(), sql_bind_data(), sql_bind_key(), and sql_step().
| static int sql_endTransaction | ( | dbiIndex | dbi | ) | [static] |
Definition at line 630 of file sqlite.c.
References _debug, _sql_db_s::db, and _sql_db_s::transaction.
Referenced by sql_cclose().
| static int sql_initDB | ( | dbiIndex | dbi | ) | [static] |
Verify the DB is setup.
. if not initialize it
Create the table.. create the db_info
Definition at line 699 of file sqlite.c.
References _debug, _free(), _sql_db_s::db, DB_EXCL, endian, RPM_BIN_TYPE, RPM_I18NSTRING_TYPE, RPM_MASK_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, RPM_UINT16_TYPE, RPM_UINT32_TYPE, RPM_UINT64_TYPE, RPM_UINT8_TYPE, RPMDBI_PACKAGES, rpmGenPath(), rpmlog(), RPMLOG_WARNING, scpFree(), scpNew(), tagName(), tagType(), and _dbswap::uc.
Referenced by sql_open().
Return handle for an index database.
| rpmdb | rpm database |
| rpmtag | rpm tag |
| *dbip | index database handle |
Definition at line 910 of file sqlite.c.
References _free(), Chmod(), D_, _sql_db_s::db, DB_PRIVATE, enterChroot(), leaveChroot(), rpmGenPath(), rpmioMkpath(), rpmlog(), RPMLOG_DEBUG, sql_busy_handler(), sql_close(), sql_initDB(), sqlitevec, stpcpy(), tagName(), _sql_db_s::transaction, urlPath(), xcalloc(), and xstrdup().
| static int sql_startTransaction | ( | dbiIndex | dbi | ) | [static] |
Definition at line 608 of file sqlite.c.
References _debug, _sql_db_s::db, and _sql_db_s::transaction.
Referenced by sql_commitTransaction(), and sql_copen().
Definition at line 353 of file sqlite.c.
References _DBSWAP, _debug, _sql_dbcursor_s::ac, _sql_dbcursor_s::av, _sql_dbcursor_s::avlen, _sql_dbcursor_s::cmd, _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().
| static int sql_sync | ( | dbiIndex | dbi, |
| unsigned int | flags | ||
| ) | [static] |
Flush pending operations to disk.
| dbi | index database handle |
| flags | (unused) |
Definition at line 1058 of file sqlite.c.
References enterChroot(), leaveChroot(), and sql_commitTransaction().
int _debug = 0 [static] |
Definition at line 66 of file sqlite.c.
Referenced by dbg_keyval(), dbg_scp(), enterChroot(), leaveChroot(), scpFree(), scpNew(), scpReset(), scpResetAv(), scpResetKeys(), sql_associate(), sql_associate_foreign(), sql_cclose(), sql_ccount(), sql_cdup(), sql_cget(), sql_commitTransaction(), sql_copen(), sql_cpget(), sql_endTransaction(), sql_exists(), sql_initDB(), sql_join(), sql_seqno(), sql_startTransaction(), and sql_step().
unsigned int endian = 0x11223344 [static] |
Definition at line 127 of file sqlite.c.
Referenced by sql_byteswapped(), and sql_initDB().
const char* sqlCwd = NULL [static] |
Definition at line 130 of file sqlite.c.
Referenced by enterChroot(), and leaveChroot().
int sqlInRoot = 0 [static] |
Definition at line 132 of file sqlite.c.
Referenced by enterChroot(), and leaveChroot().
| struct _dbiVec sqlitevec |
{
"Sqlite " SQLITE_VERSION,
((SQLITE_VERSION_NUMBER / (1000 * 1000)) % 1000),
((SQLITE_VERSION_NUMBER / ( 1000)) % 1000),
((SQLITE_VERSION_NUMBER ) % 1000),
sql_open,
sql_close,
sql_sync,
sql_associate,
sql_associate_foreign,
sql_join,
sql_exists,
sql_seqno,
sql_copen,
sql_cclose,
sql_cdup,
sql_cdel,
sql_cget,
sql_cpget,
sql_cput,
sql_ccount,
sql_byteswapped,
sql_stat
}
Definition at line 1641 of file sqlite.c.
Referenced by sql_open().
1.7.3