You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ro...@apache.org on 2006/03/08 21:28:15 UTC
svn commit: r384320 - /apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
Author: rooneg
Date: Wed Mar 8 12:28:15 2006
New Revision: 384320
URL: http://svn.apache.org/viewcvs?rev=384320&view=rev
Log:
Correct allocate space for column names in the sqlite3 dbd implementation.
Submitted by: Bojan Smojver <bojan rexursive.com>
* dbd/apr_dbd_sqlite3.c
(apr_dbd_results_t): Add col_names member.
(dbd_sqlite3_select): Initialize col_names and copy the names of the
columns into it.
Modified:
apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
Modified: apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c?rev=384320&r1=384319&r2=384320&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c Wed Mar 8 12:28:15 2006
@@ -64,6 +64,7 @@
apr_dbd_row_t *next_row;
size_t sz;
int tuples;
+ char **col_names;
};
struct apr_dbd_prepared_t {
@@ -108,6 +109,8 @@
(*results)->random = seek;
(*results)->next_row = 0;
(*results)->tuples = 0;
+ (*results)->col_names = apr_pcalloc(pool,
+ column_count * sizeof(char *));
do {
ret = sqlite3_step((*results)->stmt);
if (ret == SQLITE_BUSY) {
@@ -131,7 +134,13 @@
for (i = 0; i < (*results)->sz; i++) {
column = apr_palloc(pool, sizeof(apr_dbd_column_t));
row->columns[i] = column;
- column->name = (char *) sqlite3_column_name((*results)->stmt, i);
+ /* copy column name once only */
+ if ((*results)->col_names[i] == NULL) {
+ (*results)->col_names[i] =
+ apr_pstrdup(pool,
+ sqlite3_column_name((*results)->stmt, i));
+ }
+ column->name = (*results)->col_names[i];
column->size = sqlite3_column_bytes((*results)->stmt, i);
column->type = sqlite3_column_type((*results)->stmt, i);
column->value = NULL;