}
/*===================================================================*/
-/*
-** How This Encoder Works
-**
-** The output is allowed to contain any character except 0x27 (') and
-** 0x00. This is accomplished by using an escape character to encode
-** 0x27 and 0x00 as a two-byte sequence. The escape character is always
-** 0x01. An 0x00 is encoded as the two byte sequence 0x01 0x01. The
-** 0x27 character is encoded as the two byte sequence 0x01 0x28. Finally,
-** the escape character itself is encoded as the two-character sequence
-** 0x01 0x02.
-**
-** To summarize, the encoder works by using an escape sequences as follows:
-**
-** 0x00 -> 0x01 0x01
-** 0x01 -> 0x01 0x02
-** 0x27 -> 0x01 0x28
-**
-** If that were all the encoder did, it would work, but in certain cases
-** it could double the size of the encoded string. For example, to
-** encode a string of 100 0x27 characters would require 100 instances of
-** the 0x01 0x03 escape sequence resulting in a 200-character output.
-** We would prefer to keep the size of the encoded string smaller than
-** this.
-**
-** To minimize the encoding size, we first add a fixed offset value to each
-** byte in the sequence. The addition is modulo 256. (That is to say, if
-** the sum of the original character value and the offset exceeds 256, then
-** the higher order bits are truncated.) The offset is chosen to minimize
-** the number of characters in the string that need to be escaped. For
-** example, in the case above where the string was composed of 100 0x27
-** characters, the offset might be 0x01. Each of the 0x27 characters would
-** then be converted into an 0x28 character which would not need to be
-** escaped at all and so the 100 character input string would be converted
-** into just 100 characters of output. Actually 101 characters of output -
-** we have to record the offset used as the first byte in the sequence so
-** that the string can be decoded. Since the offset value is stored as
-** part of the output string and the output string is not allowed to contain
-** characters 0x00 or 0x27, the offset cannot be 0x00 or 0x27.
-**
-** Here, then, are the encoding steps:
-**
-** (1) Choose an offset value and make it the first character of
-** output.
-**
-** (2) Copy each input character into the output buffer, one by
-** one, adding the offset value as you copy.
-**
-** (3) If the value of an input character plus offset is 0x00, replace
-** that one character by the two-character sequence 0x01 0x01.
-** If the sum is 0x01, replace it with 0x01 0x02. If the sum
-** is 0x27, replace it with 0x01 0x03.
-**
-** (4) Put a 0x00 terminator at the end of the output.
-**
-** Decoding is obvious:
-**
-** (5) Copy encoded characters except the first into the decode
-** buffer. Set the first encoded character aside for use as
-** the offset in step 7 below.
-**
-** (6) Convert each 0x01 0x01 sequence into a single character 0x00.
-** Convert 0x01 0x02 into 0x01. Convert 0x01 0x28 into 0x27.
-**
-** (7) Subtract the offset value that was the first character of
-** the encoded buffer from all characters in the output buffer.
-**
-** The only tricky part is step (1) - how to compute an offset value to
-** minimize the size of the output buffer. This is accomplished by testing
-** all offset values and picking the one that results in the fewest number
-** of escapes. To do that, we first scan the entire input and count the
-** number of occurances of each character value in the input. Suppose
-** the number of 0x00 characters is N(0), the number of occurances of 0x01
-** is N(1), and so forth up to the number of occurances of 0xff is N(255).
-** An offset of 0 is not allowed so we don't have to test it. The number
-** of escapes required for an offset of 1 is N(1)+N(2)+N(40). The number
-** of escapes required for an offset of 2 is N(2)+N(3)+N(41). And so forth.
-** In this way we find the offset that gives the minimum number of escapes,
-** and thus minimizes the length of the output string.
-*/
-
-/*
-** Encode a binary buffer "in" of size n bytes so that it contains
-** no instances of characters '\'' or '\000'. The output is
-** null-terminated and can be used as a string value in an INSERT
-** or UPDATE statement. Use sqlite_decode_binary() to convert the
-** string back into its original binary.
-**
-** The result is written into a preallocated output buffer "out".
-** "out" must be able to hold at least 2 +(257*n)/254 bytes.
-** In other words, the output will be expanded by as much as 3
-** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
-** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
-**
-** The return value is the number of characters in the encoded
-** string, excluding the "\000" terminator.
-**
-** If out==NULL then no output is generated but the routine still returns
-** the number of characters that would have been generated if out had
-** not been NULL.
-*/
-static int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out)
- /*@modifies *out @*/
-{
- int i, j, e = 0, m;
- unsigned char x;
- int cnt[256];
- if( n<=0 ){
- if( out ){
- out[0] = 'x';
- out[1] = 0;
- }
- return 1;
- }
- memset(cnt, 0, sizeof(cnt));
- for(i=n-1; i>=0; i--){ cnt[in[i]]++; }
- m = n;
- for(i=1; i<256; i++){
- int sum;
- if( i=='\'' ) continue;
- sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff];
- if( sum<m ){
- m = sum;
- e = i;
- if( m==0 ) break;
- }
- }
- if( out==0 ){
- return n+m+1;
- }
- out[0] = e;
- j = 1;
- for(i=0; i<n; i++){
- x = in[i] - e;
- if( x==0 || x==1 || x=='\''){
- out[j++] = 1;
- x++;
- }
- out[j++] = x;
- }
- out[j] = 0;
- assert( j==n+m+1 );
- return j;
-}
-
-/*
-** Decode the string "in" into binary data and write it into "out".
-** This routine reverses the encoding created by sqlite_encode_binary().
-** The output will always be a few bytes less than the input. The number
-** of bytes of output is returned. If the input is not a well-formed
-** encoding, -1 is returned.
-**
-** The "in" and "out" parameters may point to the same buffer in order
-** to decode a string in place.
-*/
-static int sqlite_decode_binary(const unsigned char *in, unsigned char *out)
- /*@modifies *out @*/
-{
- int i, e;
- unsigned char c;
- e = *(in++);
- i = 0;
- while( (c = *(in++))!=0 ){
- if( c==1 ){
- c = *(in++) - 1;
- }
- out[i++] = c + e;
- }
- return i;
-}
-/*===================================================================*/
/*
* Transaction support
&scp->av, &scp->nr, &scp->nc, &scp->pzErrmsg);
if ( rc == 0 && scp->nr < 1 ) {
- const char * keytype;
- const char * valtype;
+ const char * keytype = "blob UNIQUE";
+ const char * valtype = "blob";
+
switch (dbi->dbi_rpmtag) {
case RPMDBI_PACKAGES:
keytype = "int UNIQUE";
valtype = "blob";
break;
- case RPMTAG_NAME:
- case RPMTAG_GROUP:
- case RPMTAG_DIRNAMES:
- case RPMTAG_BASENAMES:
- case RPMTAG_CONFLICTNAME:
- case RPMTAG_PROVIDENAME:
- case RPMTAG_PROVIDEVERSION:
- case RPMTAG_REQUIRENAME:
- case RPMTAG_REQUIREVERSION:
- keytype = "text UNIQUE";
- valtype = "blob";
- break;
default:
- keytype = "blob UNIQUE";
- valtype = "blob";
- break;
+ switch (tagType(dbi->dbi_rpmtag)) {
+ case RPM_NULL_TYPE:
+ case RPM_BIN_TYPE:
+ default:
+ break;
+ case RPM_CHAR_TYPE:
+ case RPM_INT8_TYPE:
+ case RPM_INT16_TYPE:
+ case RPM_INT32_TYPE:
+/* case RPM_INT64_TYPE: */
+ keytype = "int UNIQUE";
+ break;
+ case RPM_STRING_TYPE:
+ case RPM_STRING_ARRAY_TYPE:
+ case RPM_I18NSTRING_TYPE:
+ keytype = "text UNIQUE";
+ break;
+ }
}
- sprintf(cmd, "CREATE TABLE '%s' (key %s, value %s);",
+fprintf(stderr, "\t%s(%d) type(%d) keytype %s\n", tagName(dbi->dbi_rpmtag), dbi->dbi_rpmtag, tagType(dbi->dbi_rpmtag), keytype);
+ sprintf(cmd, "CREATE TABLE '%s' (key %s, value %s)",
dbi->dbi_subfile, keytype, valtype);
rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, &scp->pzErrmsg);
if ( rc == 0 ) {
- sprintf(cmd, "CREATE TABLE 'db_info' (endian TEXT);");
+ sprintf(cmd, "CREATE TABLE 'db_info' (endian TEXT)");
rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, &scp->pzErrmsg);
}
if ( rc == 0 ) {
- sprintf(cmd, "INSERT INTO 'db_info' values('%d');", ((union _dbswap *)&endian)->uc[0]);
+ sprintf(cmd, "INSERT INTO 'db_info' values('%d')", ((union _dbswap *)&endian)->uc[0]);
rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, &scp->pzErrmsg);
}
}
- if ( rc )
+ if (rc)
rpmMessage(RPMMESS_WARNING, "Unable to initDB %s (%d)\n",
scp->pzErrmsg, rc);
/*@modifies dbi, *dbcursor, fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
- SCP_t scp;
- SCP_t prev;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
+ SCP_t scp = sqldb->head_cursor;
+ SCP_t prev = NULL;
int rc = 0;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
-
- prev=NULL;
- scp = sqldb->head_cursor;
+assert(sqldb->db != NULL);
/* Find our version of the db3 cursor */
while ( scp != NULL && scp->name != dbcursor ) {
prev = scp;
scp = scp->next;
}
+fprintf(stderr, "==> %s(%p)\n", __FUNCTION__, scp);
assert(scp != NULL);
-fprintf(stderr, "==> %s(%p)\n", __FUNCTION__, scp);
- scp = scpReset(scp); /* Free av and avlen, reset counters.*/
-
if ( scp->memory ) {
SQL_MEM * curr_mem = scp->memory;
SQL_MEM * next_mem;
#endif
/* initialize table */
- if ( rc == 0 )
+ if (rc == 0)
rc = sql_initDB(dbi);
if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
/*@modifies fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
int rc = 0;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
+assert(sqldb->db != NULL);
#ifndef SQL_FAST_DB
rc = sql_commitTransaction(dbi, 0);
/*@modifies dbi, *txnid, *dbcp, fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
DBC * dbcursor;
SCP_t scp;
int rc = 0;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
+assert(sqldb->db != NULL);
dbcursor = xcalloc(1, sizeof(*dbcursor));
dbcursor->dbp=db;
scp = scpNew();
fprintf(stderr, "==> %s(%p)\n", __FUNCTION__, scp);
+fprintf(stderr, "\t%s(%d) type(%d)\n", tagName(dbi->dbi_rpmtag), dbi->dbi_rpmtag, tagType(dbi->dbi_rpmtag));
scp->name = dbcursor;
scp->next = sqldb->head_cursor;
sqldb->head_cursor = scp;
/*@modifies *dbcursor, fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
SCP_t scp = scpNew();
int rc = 0;
- unsigned char * kenc, * denc;
- int key_len, data_len;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
+assert(sqldb->db != NULL);
dbg_keyval(__FUNCTION__, dbi, dbcursor, key, data, flags);
- kenc = alloca (2 + ((257 * key->size)/254) + 1);
- key_len=sqlite_encode_binary((char *)key->data, key->size, kenc);
- kenc[key_len]='\0';
+ scp->cmd = sqlite3_mprintf("DELETE FROM '%q' WHERE key=? AND value=?;",
+ dbi->dbi_subfile);
- denc = alloca (2 + ((257 * data->size)/254) + 1);
- data_len=sqlite_encode_binary((char *)data->data, data->size, denc);
- denc[data_len]='\0';
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cdel(%s) prepare %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
+ rc = sqlite3_bind_text(scp->pStmt, 1, key->data, key->size, SQLITE_STATIC);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cdel(%s) bind key %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
+ rc = sqlite3_bind_text(scp->pStmt, 2, key->data, key->size, SQLITE_STATIC);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cdel(%s) bind data %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
- scp->cmd = sqlite3_mprintf("DELETE FROM '%q' WHERE key='%q' AND value='%q';",
- dbi->dbi_subfile, kenc, denc);
- rc = sqlite3_exec(sqldb->db, scp->cmd, NULL, NULL, &scp->pzErrmsg);
+ rc = sql_step(sqldb->db, scp);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cdel(%s) sql_step %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
- if ( rc )
- rpmMessage(RPMMESS_DEBUG, "cdel %s (%d)\n",
+ if (rc)
+ rpmMessage(RPMMESS_DEBUG, "cdel(%s) %s (%d)\n", dbi->dbi_subfile,
scp->pzErrmsg, rc);
scp = scpFree(scp);
/*@modifies dbi, dbcursor, *key, *data, fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
SCP_t scp;
int cleanup = 0;
int rc = 0;
- int xx;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
+assert(sqldb->db != NULL);
dbg_keyval(__FUNCTION__, dbi, dbcursor, key, data, flags);
flags);
scp->cmd = sqlite3_mprintf("SELECT key,value FROM '%q';",
dbi->dbi_subfile);
- rc = sqlite3_get_table(sqldb->db, scp->cmd,
- &scp->av, &scp->nr, &scp->nc, &scp->pzErrmsg);
+ rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cget(%s) sequential prepare %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
+
+ rc = sql_step(sqldb->db, scp);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cget(%s) sequential sql_step %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
break;
default:
- { unsigned char * kenc;
- int key_len;
/* XXX FIXME: ptr alignment is fubar here. */
-fprintf(stderr, "\tcget(%s) default key 0x%x[%d], flags %d\n",
- dbi->dbi_subfile,
- key->data == NULL ? 0 : *(long *)key->data, key->size,
- flags);
+fprintf(stderr, "\tcget(%s) default key 0x%x[%d], flags %d\n", dbi->dbi_subfile,
+ key->data == NULL ? 0 : *(long *)key->data, key->size, flags);
switch (dbi->dbi_rpmtag) {
- case RPMTAG_NAME:
-#if 0
- scp->cmd = sqlite3_mprintf("SELECT key,value FROM '%q' WHERE key='%q';",
- dbi->dbi_subfile, key->data);
- rc = sqlite3_get_table(sqldb->db, scp->cmd,
- &scp->av, &scp->nr, &scp->nc, &scp->pzErrmsg);
-#else
+ default:
scp->cmd = sqlite3_mprintf("SELECT key,value FROM '%q' WHERE key=?",
dbi->dbi_subfile);
rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
rc = sql_step(sqldb->db, scp);
if (rc) rpmMessage(RPMMESS_WARNING, "cget(%s) sql_step %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
-#endif
- break;
- case RPMTAG_GROUP:
- case RPMTAG_DIRNAMES:
- case RPMTAG_BASENAMES:
- case RPMTAG_CONFLICTNAME:
- case RPMTAG_PROVIDENAME:
- case RPMTAG_PROVIDEVERSION:
- case RPMTAG_REQUIRENAME:
- case RPMTAG_REQUIREVERSION:
- scp->cmd = sqlite3_mprintf("SELECT key,value FROM '%q' WHERE key='%q';",
- dbi->dbi_subfile, key->data);
- rc = sqlite3_get_table(sqldb->db, scp->cmd, &scp->av, &scp->nr, &scp->nc,
- &scp->pzErrmsg);
- break;
- default:
- kenc = alloca (2 + ((257 * key->size)/254) + 1);
- key_len=sqlite_encode_binary((char *)key->data, key->size, kenc);
- kenc[key_len]='\0';
-
- scp->cmd = sqlite3_mprintf("SELECT key,value FROM '%q' WHERE key='%q';",
- dbi->dbi_subfile, kenc);
- rc = sqlite3_get_table(sqldb->db, scp->cmd, &scp->av, &scp->nr, &scp->nc,
- &scp->pzErrmsg);
break;
}
-
- } break;
+ break;
}
fprintf(stderr, "\tcget(%s) got %d rows, %d columns\n",
dbi->dbi_subfile, scp->nr, scp->nc);
/* If we're looking at the whole db, return the key */
if ( scp->all ) {
- unsigned char * key_dec_string;
- int ix = ((2 * scp->rx) + 0);
- size_t key_len = strlen(scp->av[ix]);
-
- key_dec_string=alloca (2 + ((257 * key_len)/254));
+ int ix = (2 * scp->rx) + 0;
+ void * v = scp->av[ix];
+ int nb = scp->avlen[ix];
- key->size=sqlite_decode_binary(scp->av[ix],
- key_dec_string);
+fprintf(stderr, "\tcget(%s) key av[%d] = %p[%d]\n", dbi->dbi_subfile, ix, v, nb);
+ key->size = nb;
if (key->flags & DB_DBT_MALLOC)
- key->data=xmalloc(key->size);
+ key->data = xmalloc(key->size);
else
- key->data=allocTempBuffer(dbcursor, key->size);
-
- (void) memcpy( key->data, key_dec_string, key->size );
+ key->data = allocTempBuffer(dbcursor, key->size);
+ (void) memcpy(key->data, v, key->size);
}
/* Decode the data */
switch (dbi->dbi_rpmtag) {
- case RPMTAG_NAME:
+ default:
{ int ix = (2 * scp->rx) + 1;
void * v = scp->av[ix];
int nb = scp->avlen[ix];
-fprintf(stderr, "\tcget(%s) av[%d] = %p[%d]\n",
- dbi->dbi_subfile, ix, v, nb);
+fprintf(stderr, "\tcget(%s) data av[%d] = %p[%d]\n", dbi->dbi_subfile, ix, v, nb);
data->size = nb;
if (data->flags & DB_DBT_MALLOC)
data->data = allocTempBuffer(dbcursor, data->size);
(void) memcpy(data->data, v, data->size);
} break;
- default:
- { unsigned char * data_dec_string;
- int ix = (2 * scp->rx) + 1;
- size_t data_len=strlen(scp->av[ix]);
-
- data_dec_string=alloca (2 + ((257 * data_len)/254));
-
- data->size=sqlite_decode_binary(
- scp->av[ix],
- data_dec_string);
-
- if (data->flags & DB_DBT_MALLOC)
- data->data=xmalloc(data->size);
- else
- data->data=allocTempBuffer(dbcursor, data->size);
-
- (void) memcpy( data->data, data_dec_string, data->size );
- } break;
}
/* We need to skip this entry... (we've already returned it) */
scp->all > 1 &&
key->size ==4 && *(long *)key->data == 0 )
{
-fprintf(stderr, "\tcget(%s) skipping 0x0 record\n",
- dbi->dbi_subfile);
+fprintf(stderr, "\tcget(%s) skipping 0x0 record\n", dbi->dbi_subfile);
goto repeat;
}
/* XXX FIXME: ptr alignment is fubar here. */
-fprintf(stderr, "\tcget(%s) found key 0x%x (%d)\n",
- dbi->dbi_subfile,
- key->data == NULL ? 0 : *(long *)key->data, key->size
- );
-fprintf(stderr, "\tcget(%s) found data 0x%x (%d)\n",
- dbi->dbi_subfile,
- key->data == NULL ? 0 : *(long *)data->data, data->size
- );
+fprintf(stderr, "\tcget(%s) found key 0x%x (%d)\n", dbi->dbi_subfile,
+ key->data == NULL ? 0 : *(long *)key->data, key->size);
+fprintf(stderr, "\tcget(%s) found data 0x%x (%d)\n", dbi->dbi_subfile,
+ key->data == NULL ? 0 : *(long *)data->data, data->size);
}
}
fprintf(stderr, "\tcget(%s) not found\n", dbi->dbi_subfile);
/* If we retrieved the 0x0 record.. clear so next pass we'll get them all.. */
- if ( scp->all == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES )
+ if (scp->all == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES)
scp = scpReset(scp); /* Free av and avlen, reset counters.*/
if (cleanup)
/*@modifies *dbcursor, fileSystem @*/
{
DB * db = dbi->dbi_db;
- SQL_DB * sqldb;
+ SQL_DB * sqldb = (SQL_DB *)db->app_private;
SCP_t scp = scpNew();
- unsigned char * kenc, * denc;
- int key_len, data_len;
int rc = 0;
- int xx;
- assert(db != NULL);
- sqldb = (SQL_DB *)db->app_private;
- assert(sqldb != NULL && sqldb->db != NULL);
+assert(sqldb->db != NULL);
dbg_keyval(__FUNCTION__, dbi, dbcursor, key, data, flags);
switch (dbi->dbi_rpmtag) {
default:
- kenc = alloca (2 + ((257 * key->size)/254) + 1);
- key_len=sqlite_encode_binary((char *)key->data, key->size, kenc);
- kenc[key_len]='\0';
-
- denc = alloca (2 + ((257 * data->size)/254) + 1);
- data_len=sqlite_encode_binary((char *)data->data, data->size, denc);
- denc[data_len]='\0';
-
- scp->cmd = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' VALUES('%q', '%q');",
- dbi->dbi_subfile, kenc, denc);
- rc = sqlite3_exec(sqldb->db, scp->cmd, NULL, NULL, &scp->pzErrmsg);
- if (rc)
- rpmMessage(RPMMESS_WARNING, "cput %s (%d)\n", scp->pzErrmsg, rc);
- break;
- case RPMTAG_NAME:
scp->cmd = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' VALUES(?, ?);",
dbi->dbi_subfile);
rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput prepare %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cput(%s) prepare %s (%d)\n",dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sqlite3_bind_text(scp->pStmt, 1, key->data, key->size, SQLITE_STATIC);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput bind #1 %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cput(%s) key bind %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sqlite3_bind_blob(scp->pStmt, 2, data->data, data->size, SQLITE_STATIC);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput bind #2 %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cput(%s) data bind %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
rc = sql_step(sqldb->db, scp);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput sql_step %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
+ if (rc) rpmMessage(RPMMESS_WARNING, "cput(%s) sql_step %s (%d)\n", dbi->dbi_subfile, sqlite3_errmsg(sqldb->db), rc);
break;
- case RPMTAG_GROUP:
- case RPMTAG_DIRNAMES:
- case RPMTAG_BASENAMES:
- case RPMTAG_CONFLICTNAME:
- case RPMTAG_PROVIDENAME:
- case RPMTAG_PROVIDEVERSION:
- case RPMTAG_REQUIRENAME:
- case RPMTAG_REQUIREVERSION:
- denc = alloca (2 + ((257 * data->size)/254) + 1);
- data_len=sqlite_encode_binary((char *)data->data, data->size, denc);
- denc[data_len]='\0';
-
-#if 1
- scp->cmd = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' VALUES('%q', '%q');",
- dbi->dbi_subfile, key->data, denc);
- rc = sqlite3_exec(sqldb->db, scp->cmd, NULL, NULL, &scp->pzErrmsg);
- if (rc)
- rpmMessage(RPMMESS_WARNING, "cput %s (%d)\n", scp->pzErrmsg, rc);
-#else
- scp->cmd = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' VALUES(?, ?);",
- dbi->dbi_subfile);
- rc = sqlite3_prepare(sqldb->db, scp->cmd, strlen(scp->cmd), &scp->pStmt, &scp->pzErrmsg);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput prepare %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
- rc = sqlite3_bind_text(scp->pStmt, 1, key->data, key->size, SQLITE_STATIC);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput bind #2 %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
-#ifdef HACKHERE
- rc = sqlite3_bind_blob(scp->pStmt, 2, data->data, data->size, SQLITE_STATIC);
-#else
- rc = sqlite3_bind_blob(scp->pStmt, 2, denc, data_len, SQLITE_STATIC);
-#endif
- if (rc) rpmMessage(RPMMESS_WARNING, "cput bind #3 %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
-
- rc = sql_step(sqldb->db, scp);
- if (rc) rpmMessage(RPMMESS_WARNING, "cput sql_step %s (%d)\n", sqlite3_errmsg(sqldb->db), rc);
-
-#endif
- break;
}
scp = scpFree(scp);