Hi Garrett,
Sure, no problem.
1) relock the mutex after a retry in the
dbd_sqlite3_select function.
2) remove break from the return of a float value from
SQLite and initialize the value to NULL. The value was
never being returned.
3) remove unnecessary creation and destruction of
apr_pool in dbd_sqlite3_query function.
4) Remove the res variable in the dbd_sqlite3_query
function.
There were some changes after this review and the
updated patch file is attached.
Thanks,
Rick Keiner
--- Garrett Rooney <[EMAIL PROTECTED]>
wrote:
> Rick Keiner wrote:
> > Hi Paul,
> >
> > I've attached a patch to the SQLite 3 driver that
> > fixes some initialization issues and returns float
> > data. This has been tested with the
> jxta-c.jxta.org
> > project and no major issues. If we could get it in
> the
> > release that would be great! We are relying on
> this
> > patch to be part of the release.
>
> I'd love to commit this patch, but it seems to do a
> number of different
> things, and since I don't know all that much about
> the internals of the
> sqlite3 dbd I can't confirm if they're right or
> wrong. Could you
> perhaps write a log message that explains exactly
> what problems are
> being corrected here (in addition to the addition of
> the new float data
> feature).
>
> Thanks,
>
> -garrett
>
Index: dbd/apr_dbd_sqlite3.c
===================================================================
--- dbd/apr_dbd_sqlite3.c (revision 232627)
+++ dbd/apr_dbd_sqlite3.c (working copy)
@@ -117,6 +117,7 @@
} else {
apr_thread_mutex_unlock(sql->mutex);
apr_sleep(MAX_RETRY_SLEEP);
+ apr_thread_mutex_lock(sql->mutex);
}
} else if (ret == SQLITE_ROW) {
int length;
@@ -134,23 +135,22 @@
column->name = (char *) sqlite3_column_name((*results)->stmt, i);
column->size = sqlite3_column_bytes((*results)->stmt, i);
column->type = sqlite3_column_type((*results)->stmt, i);
+ column->value = NULL;
switch (column->type) {
-
- case SQLITE_FLOAT:
- break;
- case SQLITE_INTEGER:
- case SQLITE_TEXT:
- hold = NULL;
- hold = (char *) sqlite3_column_text((*results)->stmt, i);
- if (hold) {
- column->value = apr_palloc(pool, column->size + 1);
- strncpy(column->value, hold, column->size + 1);
- }
- break;
- case SQLITE_BLOB:
- break;
- case SQLITE_NULL:
- break;
+ case SQLITE_FLOAT:
+ case SQLITE_INTEGER:
+ case SQLITE_TEXT:
+ hold = NULL;
+ hold = (char *) sqlite3_column_text((*results)->stmt, i);
+ if (hold) {
+ column->value = apr_palloc(pool, column->size + 1);
+ strncpy(column->value, hold, column->size + 1);
+ }
+ break;
+ case SQLITE_BLOB:
+ break;
+ case SQLITE_NULL:
+ break;
}
col = row->columns[i];
}
@@ -226,19 +226,12 @@
{
sqlite3_stmt *stmt = NULL;
const char *tail = NULL;
- int ret, length = 0;
- apr_status_t res;
- apr_pool_t *pool;
+ int ret = -1, length = 0;
if (sql->trans && sql->trans->errnum) {
return sql->trans->errnum;
}
- res = apr_pool_create(&pool, sql->pool);
- if (res != APR_SUCCESS) {
- sql->trans->errnum = res;
- return SQLITE_ERROR;
- }
length = strlen(query);
apr_thread_mutex_lock(sql->mutex);
@@ -248,7 +241,6 @@
sqlite3_finalize(stmt);
break;
}
-
ret = sqlite3_step(stmt);
*nrows = sqlite3_changes(sql->conn);
sqlite3_finalize(stmt);
@@ -257,14 +249,13 @@
} while (length > 0);
if (dbd_sqlite3_is_success(ret)) {
- res = 0;
+ ret = 0;
}
apr_thread_mutex_unlock(sql->mutex);
- apr_pool_destroy(pool);
if (sql->trans) {
- sql->trans->errnum = res;
+ sql->trans->errnum = ret;
}
- return res;
+ return ret;
}
static const char *dbd_sqlite3_escape(apr_pool_t *pool, const char *arg,