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 2005/02/05 20:18:49 UTC
svn commit: r151521 - in apr/apr-util/trunk: dbd/apr_dbd.c
dbd/apr_dbd_pgsql.c include/apr_dbd.h test/testdbd.c
Author: rooneg
Date: Sat Feb 5 11:18:47 2005
New Revision: 151521
URL: http://svn.apache.org/viewcvs?view=rev&rev=151521
Log:
* include/apr_dbd.h
(apr_dbd_transaction,
apr_dbd_results,
apr_dbd_row,
apr_dbd_prepared): in the interest of consistency, add _t to the end
of these typedefs.
(apr_dbd_driver_t,
apr_dbd_transaction_start,
apr_dbd_transaction_end,
apr_dbd_query,
apr_dbd_select,
apr_dbd_num_cols,
apr_dbd_num_tuples,
apr_dbd_get_row,
apr_dbd_get_entry,
apr_dbd_prepare,
apr_dbd_pquery,
apr_dbd_pselect): update all uses of those typedefs.
* test/testdbd.c: update all uses of those typedefs.
* dbd/apr_dbd_pgsql.c: ditto.
* dbd/apr_dbd.c: ditto.
Modified:
apr/apr-util/trunk/dbd/apr_dbd.c
apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
apr/apr-util/trunk/include/apr_dbd.h
apr/apr-util/trunk/test/testdbd.c
Modified: apr/apr-util/trunk/dbd/apr_dbd.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd.c?view=diff&r1=151520&r2=151521
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd.c Sat Feb 5 11:18:47 2005
@@ -153,7 +153,7 @@
}
APU_DECLARE(int) apr_dbd_transaction_start(apr_dbd_driver_t *driver,
apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction **trans)
+ apr_dbd_transaction_t **trans)
{
int ret = driver->start_transaction(pool, handle, trans);
if (*trans) {
@@ -164,7 +164,7 @@
}
APU_DECLARE(int) apr_dbd_transaction_end(apr_dbd_driver_t *driver,
apr_pool_t *pool,
- apr_dbd_transaction *trans)
+ apr_dbd_transaction_t *trans)
{
apr_pool_cleanup_kill(pool, trans, (void*)driver->end_transaction);
return driver->end_transaction(trans);
Modified: apr/apr-util/trunk/dbd/apr_dbd_pgsql.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd_pgsql.c?view=diff&r1=151520&r2=151521
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_pgsql.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_pgsql.c Sat Feb 5 11:18:47 2005
@@ -34,7 +34,7 @@
typedef struct {
int errnum;
PGconn *handle;
-} apr_dbd_transaction;
+} apr_dbd_transaction_t;
typedef struct {
int random;
@@ -43,17 +43,17 @@
size_t ntuples;
size_t sz;
size_t index;
-} apr_dbd_results;
+} apr_dbd_results_t;
typedef struct {
int n;
- apr_dbd_results *res;
-} apr_dbd_row;
+ apr_dbd_results_t *res;
+} apr_dbd_row_t;
-typedef struct apr_dbd_prepared {
+typedef struct {
const char *name;
int prepared;
-} apr_dbd_prepared;
+} apr_dbd_prepared_t;
#define dbd_pgsql_is_success(x) (((x) == PGRES_EMPTY_QUERY) \
|| ((x) == PGRES_COMMAND_OK) \
@@ -63,8 +63,8 @@
#include "apr_dbd.h"
static int dbd_pgsql_select(apr_pool_t *pool, apr_dbd_t *sql,
- apr_dbd_transaction *trans,
- apr_dbd_results **results,
+ apr_dbd_transaction_t *trans,
+ apr_dbd_results_t **results,
const char *query, int seek)
{
PGresult *res;
@@ -91,7 +91,7 @@
return ret;
}
if (!*results) {
- *results = apr_pcalloc(pool, sizeof(apr_dbd_results));
+ *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t));
}
(*results)->res = res;
(*results)->ntuples = PQntuples(res);
@@ -108,7 +108,7 @@
return 1;
}
if (*results == NULL) {
- *results = apr_pcalloc(pool, sizeof(apr_dbd_results));
+ *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t));
}
(*results)->random = seek;
(*results)->handle = sql->conn;
@@ -116,14 +116,14 @@
return 0;
}
-static int dbd_pgsql_get_row(apr_pool_t *pool, apr_dbd_results *res,
- apr_dbd_row **rowp, int rownum)
+static int dbd_pgsql_get_row(apr_pool_t *pool, apr_dbd_results_t *res,
+ apr_dbd_row_t **rowp, int rownum)
{
- apr_dbd_row *row = *rowp;
+ apr_dbd_row_t *row = *rowp;
int sequential = ((rownum >= 0) && res->random) ? 0 : 1;
if (row == NULL) {
- row = apr_palloc(pool, sizeof(apr_dbd_row));
+ row = apr_palloc(pool, sizeof(apr_dbd_row_t));
*rowp = row;
row->res = res;
row->n = sequential ? 0 : rownum;
@@ -181,7 +181,7 @@
return 0;
}
-static const char *dbd_pgsql_get_entry(const apr_dbd_row *row, int n)
+static const char *dbd_pgsql_get_entry(const apr_dbd_row_t *row, int n)
{
return PQgetvalue(row->res->res, row->n, n);
}
@@ -191,7 +191,7 @@
return PQerrorMessage(sql->conn);
}
-static int dbd_pgsql_query(apr_dbd_t *sql, apr_dbd_transaction *trans,
+static int dbd_pgsql_query(apr_dbd_t *sql, apr_dbd_transaction_t *trans,
int *nrows, const char *query)
{
PGresult *res;
@@ -229,7 +229,7 @@
static int dbd_pgsql_prepare(apr_pool_t *pool, apr_dbd_t *sql,
const char *query, const char *label,
- apr_dbd_prepared **statement)
+ apr_dbd_prepared_t **statement)
{
char *sqlcmd;
char *sqlptr;
@@ -244,7 +244,7 @@
char *pgptr;
if (!*statement) {
- *statement = apr_palloc(pool, sizeof(apr_dbd_prepared));
+ *statement = apr_palloc(pool, sizeof(apr_dbd_prepared_t));
}
/* Translate from apr_dbd to native query format */
for (sqlptr = (char*)query; *sqlptr; ++sqlptr) {
@@ -344,8 +344,8 @@
}
static int dbd_pgsql_pquery(apr_pool_t *pool, apr_dbd_t *sql,
- apr_dbd_transaction *trans, int *nrows,
- apr_dbd_prepared *statement, int nargs,
+ apr_dbd_transaction_t *trans, int *nrows,
+ apr_dbd_prepared_t *statement, int nargs,
const char **values)
{
int ret;
@@ -376,8 +376,8 @@
}
static int dbd_pgsql_pvquery(apr_pool_t *pool, apr_dbd_t *sql,
- apr_dbd_transaction *trans, int *nrows,
- apr_dbd_prepared *statement, ...)
+ apr_dbd_transaction_t *trans, int *nrows,
+ apr_dbd_prepared_t *statement, ...)
{
const char *arg;
int nargs = 0;
@@ -401,9 +401,9 @@
}
static int dbd_pgsql_pselect(apr_pool_t *pool, apr_dbd_t *sql,
- apr_dbd_transaction *trans,
- apr_dbd_results **results,
- apr_dbd_prepared *statement,
+ apr_dbd_transaction_t *trans,
+ apr_dbd_results_t **results,
+ apr_dbd_prepared_t *statement,
int seek, int nargs, const char **values)
{
PGresult *res;
@@ -437,7 +437,7 @@
return ret;
}
if (!*results) {
- *results = apr_pcalloc(pool, sizeof(apr_dbd_results));
+ *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t));
}
(*results)->res = res;
(*results)->ntuples = PQntuples(res);
@@ -462,7 +462,7 @@
return 1;
}
if (!*results) {
- *results = apr_pcalloc(pool, sizeof(apr_dbd_results));
+ *results = apr_pcalloc(pool, sizeof(apr_dbd_results_t));
}
(*results)->random = seek;
(*results)->handle = sql->conn;
@@ -475,9 +475,9 @@
}
static int dbd_pgsql_pvselect(apr_pool_t *pool, apr_dbd_t *sql,
- apr_dbd_transaction *trans,
- apr_dbd_results **results,
- apr_dbd_prepared *statement,
+ apr_dbd_transaction_t *trans,
+ apr_dbd_results_t **results,
+ apr_dbd_prepared_t *statement,
int seek, ...)
{
const char *arg;
@@ -503,7 +503,7 @@
}
static int dbd_pgsql_transaction(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction **trans)
+ apr_dbd_transaction_t **trans)
{
int ret = 0;
PGresult *res = PQexec(handle->conn, "BEGIN TRANSACTION");
@@ -512,7 +512,7 @@
if (dbd_pgsql_is_success(ret)) {
ret = 0;
if (!*trans) {
- *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction));
+ *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t));
}
}
PQclear(res);
@@ -524,7 +524,7 @@
return ret;
}
-static int dbd_pgsql_end_transaction(apr_dbd_transaction *trans)
+static int dbd_pgsql_end_transaction(apr_dbd_transaction_t *trans)
{
PGresult *res;
int ret = -1; /* no transaction is an error cond */
@@ -601,12 +601,12 @@
return handle->conn;
}
-static int dbd_pgsql_num_cols(apr_dbd_results* res)
+static int dbd_pgsql_num_cols(apr_dbd_results_t* res)
{
return res->sz;
}
-static int dbd_pgsql_num_tuples(apr_dbd_results* res)
+static int dbd_pgsql_num_tuples(apr_dbd_results_t* res)
{
if (res->random) {
return res->ntuples;
Modified: apr/apr-util/trunk/include/apr_dbd.h
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/include/apr_dbd.h?view=diff&r1=151520&r2=151521
==============================================================================
--- apr/apr-util/trunk/include/apr_dbd.h (original)
+++ apr/apr-util/trunk/include/apr_dbd.h Sat Feb 5 11:18:47 2005
@@ -37,10 +37,10 @@
/* These are opaque structs. Instantiation is up to each backend */
#ifndef APR_DBD_INTERNAL
typedef struct apr_dbd_t apr_dbd_t;
-typedef struct apr_dbd_transaction apr_dbd_transaction;
-typedef struct apr_dbd_results apr_dbd_results;
-typedef struct apr_dbd_row apr_dbd_row;
-typedef struct apr_dbd_prepared apr_dbd_prepared;
+typedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
+typedef struct apr_dbd_results_t apr_dbd_results_t;
+typedef struct apr_dbd_row_t apr_dbd_row_t;
+typedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
#endif
typedef struct apr_dbd_driver_t {
@@ -102,7 +102,7 @@
* @return 0 for success or error code
*/
int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction **trans);
+ apr_dbd_transaction_t **trans);
/** end_transaction: end a transaction
* (commit on success, rollback on error).
@@ -111,7 +111,7 @@
* @param transaction - the transaction.
* @return 0 for success or error code
*/
- int (*end_transaction)(apr_dbd_transaction *trans);
+ int (*end_transaction)(apr_dbd_transaction_t *trans);
/** query: execute an SQL query that doesn't return a result set
*
@@ -121,7 +121,7 @@
* @param statement - the SQL statement to execute
* @return 0 for success or error code
*/
- int (*query)(apr_dbd_t *handle, apr_dbd_transaction *trans,
+ int (*query)(apr_dbd_t *handle, apr_dbd_transaction_t *trans,
int *nrows, const char *statement);
/** select: execute an SQL query that returns a result set
@@ -137,7 +137,7 @@
* @return 0 for success or error code
*/
int (*select)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction *trans, apr_dbd_results **res,
+ apr_dbd_transaction_t *trans, apr_dbd_results_t **res,
const char *statement, int random);
/** num_cols: get the number of columns in a results set
@@ -145,7 +145,7 @@
* @param res - result set.
* @return number of columns
*/
- int (*num_cols)(apr_dbd_results *res);
+ int (*num_cols)(apr_dbd_results_t *res);
/** num_tuples: get the number of rows in a results set
* of a synchronous select
@@ -153,7 +153,7 @@
* @param res - result set.
* @return number of rows, or -1 if the results are asynchronous
*/
- int (*num_tuples)(apr_dbd_results *res);
+ int (*num_tuples)(apr_dbd_results_t *res);
/** get_row: get a row from a result set
*
@@ -164,8 +164,8 @@
* access is not supported.
* @return 0 for success, -1 for rownum out of range or data finished
*/
- int (*get_row)(apr_pool_t *pool, apr_dbd_results *res,
- apr_dbd_row **row, int rownum);
+ int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res,
+ apr_dbd_row_t **row, int rownum);
/** get_entry: get an entry from a row
*
@@ -173,7 +173,7 @@
* @param col - entry number
* @return value from the row, or NULL if col is out of bounds.
*/
- const char *(*get_entry)(const apr_dbd_row *row, int col);
+ const char *(*get_entry)(const apr_dbd_row_t *row, int col);
/** error: get current error message (if any)
*
@@ -206,7 +206,7 @@
* @return 0 for success or error code
*/
int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query,
- const char *label, apr_dbd_prepared **statement);
+ const char *label, apr_dbd_prepared_t **statement);
/** pvquery: query using a prepared statement + args
*
@@ -219,8 +219,8 @@
* @return 0 for success or error code
*/
int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction *trans, int *nrows,
- apr_dbd_prepared *statement, ...);
+ apr_dbd_transaction_t *trans, int *nrows,
+ apr_dbd_prepared_t *statement, ...);
/** pvselect: select using a prepared statement + args
*
@@ -234,8 +234,8 @@
* @return 0 for success or error code
*/
int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction *trans, apr_dbd_results **res,
- apr_dbd_prepared *statement, int random, ...);
+ apr_dbd_transaction_t *trans, apr_dbd_results_t **res,
+ apr_dbd_prepared_t *statement, int random, ...);
/** pquery: query using a prepared statement + args
*
@@ -249,8 +249,8 @@
* @return 0 for success or error code
*/
int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction *trans, int *nrows,
- apr_dbd_prepared *statement, int nargs, const char **args);
+ apr_dbd_transaction_t *trans, int *nrows,
+ apr_dbd_prepared_t *statement, int nargs, const char **args);
/** pselect: select using a prepared statement + args
*
@@ -265,8 +265,8 @@
* @return 0 for success or error code
*/
int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle,
- apr_dbd_transaction *trans, apr_dbd_results **res,
- apr_dbd_prepared *statement, int random, int nargs,
+ apr_dbd_transaction_t *trans, apr_dbd_results_t **res,
+ apr_dbd_prepared_t *statement, int random, int nargs,
const char **args);
@@ -388,7 +388,7 @@
APU_DECLARE(int) apr_dbd_transaction_start(apr_dbd_driver_t *driver,
apr_pool_t *pool,
apr_dbd_t *handle,
- apr_dbd_transaction **trans);
+ apr_dbd_transaction_t **trans);
/** apr_dbd_transaction_end: end a transaction
* (commit on success, rollback on error).
@@ -401,7 +401,7 @@
*/
APU_DECLARE(int) apr_dbd_transaction_end(apr_dbd_driver_t *driver,
apr_pool_t *pool,
- apr_dbd_transaction *trans);
+ apr_dbd_transaction_t *trans);
#ifdef DOXYGEN
/** apr_dbd_query: execute an SQL query that doesn't return a result set
@@ -414,7 +414,7 @@
* @return 0 for success or error code
*/
APU_DECLARE(int) apr_dbd_query(apr_dbd_driver_t *driver, apr_dbd_t *handle,
- apr_dbd_transaction *trans, int *nrows,
+ apr_dbd_transaction_t *trans, int *nrows,
const char *statement);
#else
#define apr_dbd_query(driver,handle,trans,nrows,statement) \
@@ -436,8 +436,8 @@
* @return 0 for success or error code
*/
APU_DECLARE(int) apr_dbd_select(apr_dbd_driver_t *driver, apr_pool_t *pool,
- apr_dbd_t *handle, apr_dbd_transaction *trans,
- apr_dbd_results *res, const char *statement,
+ apr_dbd_t *handle, apr_dbd_transaction_t *trans,
+ apr_dbd_results_t *res, const char *statement,
int random);
#else
#define apr_dbd_select(driver,pool,handle,trans,res,statement,random) \
@@ -452,7 +452,7 @@
* @return number of columns
*/
APU_DECLARE(int) apr_dbd_num_cols(apr_dbd_driver_t *driver,
- apr_dbd_results *res);
+ apr_dbd_results_t *res);
#else
#define apr_dbd_num_cols(driver,res) \
(driver)->num_cols((res))
@@ -467,7 +467,7 @@
* @return number of rows, or -1 if the results are asynchronous
*/
APU_DECLARE(int) apr_dbd_num_tuples(apr_dbd_driver_t *driver,
- apr_dbd_results *res);
+ apr_dbd_results_t *res);
#else
#define apr_dbd_num_tuples(driver,res) \
(driver)->num_tuples((res))
@@ -485,7 +485,7 @@
* @return 0 for success, -1 for rownum out of range or data finished
*/
APU_DECLARE(int) apr_dbd_get_row(apr_dbd_driver_t *driver, apr_pool_t *pool,
- apr_dbd_results *res, apr_dbd_row **row,
+ apr_dbd_results_t *res, apr_dbd_row_t **row,
int rownum);
#else
#define apr_dbd_get_row(driver,pool,res,row,rownum) \
@@ -501,7 +501,7 @@
* @return value from the row, or NULL if col is out of bounds.
*/
APU_DECLARE(const char*) apr_dbd_get_entry(apr_dbd_driver_t *driver,
- apr_dbd_row *row, int col);
+ apr_dbd_row_t *row, int col);
#else
#define apr_dbd_get_entry(driver,row,col) \
(driver)->get_entry((row),(col))
@@ -556,7 +556,7 @@
APU_DECLARE(int) apr_dbd_prepare(apr_dbd_driver_t *driver, apr_pool_t *pool,
apr_dbd_t *handle, const char *query,
const char *label,
- apr_dbd_prepared **statement);
+ apr_dbd_prepared_t **statement);
#else
#define apr_dbd_prepare(driver,pool,handle,query,label,statement) \
(driver)->prepare((pool),(handle),(query),(label),(statement))
@@ -580,8 +580,8 @@
* @return 0 for success or error code
*/
APU_DECLARE(int) apr_dbd_pquery(apr_dbd_driver_t *driver, apr_pool_t *pool,
- apr_dbd_t *handle, apr_dbd_transaction *trans,
- int *nrows, apr_dbd_prepared *statement,
+ apr_dbd_t *handle, apr_dbd_transaction_t *trans,
+ int *nrows, apr_dbd_prepared_t *statement,
int nargs, const char **args);
#else
#define apr_dbd_pquery(driver,pool,handle,trans,nrows,statement,nargs,args) \
@@ -604,9 +604,9 @@
* @return 0 for success or error code
*/
APU_DECLARE(int) apr_dbd_pselect(apr_dbd_driver_t *driver, apr_pool_t *pool,
- apr_dbd_t *handle, apr_dbd_transaction *trans,
- apr_dbd_results **res,
- apr_dbd_prepared *statement, int random,
+ apr_dbd_t *handle, apr_dbd_transaction_t *trans,
+ apr_dbd_results_t **res,
+ apr_dbd_prepared_t *statement, int random,
int nargs, const char **args);
#else
#define apr_dbd_pselect(driver,pool,handle,trans,res,statement,random,nargs,args) \
Modified: apr/apr-util/trunk/test/testdbd.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/test/testdbd.c?view=diff&r1=151520&r2=151521
==============================================================================
--- apr/apr-util/trunk/test/testdbd.c (original)
+++ apr/apr-util/trunk/test/testdbd.c Sat Feb 5 11:18:47 2005
@@ -112,8 +112,8 @@
int n;
const char* entry;
const char* statement = "SELECT * FROM apr_dbd_test ORDER BY col1, col2";
- apr_dbd_results *res = NULL;
- apr_dbd_row *row = NULL;
+ apr_dbd_results_t *res = NULL;
+ apr_dbd_row_t *row = NULL;
rv = apr_dbd_select(driver,pool,handle,NULL,&res,statement,0);
if (rv) {
printf("Select failed: %s", apr_dbd_error(driver, handle, rv));
@@ -143,8 +143,8 @@
int n;
const char* entry;
const char* statement = "SELECT * FROM apr_dbd_test ORDER BY col1, col2";
- apr_dbd_results *res = NULL;
- apr_dbd_row *row = NULL;
+ apr_dbd_results_t *res = NULL;
+ apr_dbd_row_t *row = NULL;
rv = apr_dbd_select(driver,pool,handle,NULL,&res,statement,1);
if (rv) {
printf("Select failed: %s", apr_dbd_error(driver, handle, rv));
@@ -197,7 +197,7 @@
{
int rv = 0;
int nrows;
- apr_dbd_transaction* trans = NULL;
+ apr_dbd_transaction_t *trans = NULL;
const char* statement;
/* trans 1 - error out early */
@@ -273,9 +273,9 @@
const char *query =
"SELECT * FROM apr_dbd_test WHERE col3 <= %s or col1 = 'bar'" ;
const char *label = "lowvalues";
- apr_dbd_prepared* statement = NULL;
- apr_dbd_results* res = NULL;
- apr_dbd_row* row = NULL;
+ apr_dbd_prepared_t *statement = NULL;
+ apr_dbd_results_t *res = NULL;
+ apr_dbd_row_t *row = NULL;
const char *entry = NULL;
rv = apr_dbd_prepare(driver, pool, handle, query, label, &statement);
@@ -314,10 +314,10 @@
{
int rv = 0;
const char *query = "INSERT INTO apr_dbd_test VALUES (%s, %s, %d)";
- apr_dbd_prepared *statement = NULL;
+ apr_dbd_prepared_t *statement = NULL;
const char *label = "testpquery";
int nrows;
- apr_dbd_transaction* trans =0;
+ apr_dbd_transaction_t *trans =0;
rv = apr_dbd_prepare(driver, pool, handle, query, label, &statement);
//rv = apr_dbd_prepare(driver, pool, handle, query, NULL, &statement);