aboutsummaryrefslogtreecommitdiff
path: root/src/sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql.c')
-rw-r--r--src/sql.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/sql.c b/src/sql.c
index b8c1d42..c81d4fb 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -54,16 +54,16 @@ sql_connection_exists_p (const char *ident)
return sql_find_connection (ident) != NULL;
}
-/* Initialize MySQL access method */
+/* Initialize MySQL dictionary */
int
-sql_init_method (struct access_method *method)
+sql_init_dictionary (struct dictionary *dict)
{
- struct sqlconn *conn = sql_find_connection (method->parmv[0]);
+ struct sqlconn *conn = sql_find_connection (dict->parmv[0]);
if (!conn)
{
logmsg (LOG_EMERG, _("INTERNAL ERROR: cannot find SQL connection %s"),
- method->parmv[0]);
+ dict->parmv[0]);
abort ();
}
@@ -78,22 +78,22 @@ sql_init_method (struct access_method *method)
conn->socket, 0))
{
logmsg (LOG_ERR, _("failed to connect to database %s: error: %s\n"),
- method->parmv[0], mysql_error (&conn->mysql));
+ dict->parmv[0], mysql_error (&conn->mysql));
return 1;
}
}
- method->storage = conn;
+ dict->storage = conn;
return 0;
}
void *
-sql_open (struct access_method *method)
+sql_open (struct dictionary *dict)
{
- return method->storage;
+ return dict->storage;
}
int
-sql_free_result (struct access_method *method, void *handle)
+sql_free_result (struct dictionary *dict, void *handle)
{
struct sqlconn *conn = handle;
if (conn->result)
@@ -104,31 +104,31 @@ sql_free_result (struct access_method *method, void *handle)
return 0;
}
-/* Finish the initialized MySQL access method */
+/* Finish the initialized MySQL dictionary */
int
-sql_done_method (struct access_method *method)
+sql_done_dictionary (struct dictionary *dict)
{
- struct sqlconn *conn = method->storage;
+ struct sqlconn *conn = dict->storage;
if (!conn || conn->initcount == 0)
return 0;
if (--conn->initcount)
return 0;
- sql_free_result (method, conn); /* FIXME: Not needed */
+ sql_free_result (dict, conn); /* FIXME: Not needed */
mysql_close (&conn->mysql);
- method->storage = NULL;
+ dict->storage = NULL;
return 0;
}
/* Execute QUERY using the given access METHOD. Return 0 on success. */
int
-sql_run_method (struct access_method *method, void *handle, const char *query)
+sql_lookup_dictionary (struct dictionary *dict, void *handle, const char *query)
{
struct sqlconn *conn = handle;
MYSQL *mysql = &conn->mysql;
if (!query)
{
- logmsg (LOG_ERR, _("no query supplied for method %s"), "sql");
+ logmsg (LOG_ERR, _("no query supplied for dictionary %s"), "sql");
return 1;
}
@@ -147,12 +147,12 @@ sql_run_method (struct access_method *method, void *handle, const char *query)
return 1;
}
- method->nrow = mysql_num_rows (conn->result);
- method->ncol = mysql_num_fields (conn->result);
+ dict->nrow = mysql_num_rows (conn->result);
+ dict->ncol = mysql_num_fields (conn->result);
if (debug_level > 1)
{
logmsg (LOG_DEBUG, _("query returned %u columns in %u rows"),
- method->ncol, method->nrow);
+ dict->ncol, dict->nrow);
logmsg (LOG_DEBUG, _("the query was: %s"), query);
}
@@ -160,7 +160,7 @@ sql_run_method (struct access_method *method, void *handle, const char *query)
}
int
-sql_get_method (struct access_method *method, void *handle,
+sql_get_dictionary (struct dictionary *dict, void *handle,
unsigned nrow, unsigned ncol)
{
struct sqlconn *conn = handle;
@@ -176,12 +176,12 @@ sql_get_method (struct access_method *method, void *handle,
else
len = trim_length (row[ncol]);
- method_copy_result (method, row[ncol], len);
+ dictionary_copy_result (dict, row[ncol], len);
return 0;
}
int
-sql_quote (struct access_method *method, void *handle, const char *input,
+sql_quote (struct dictionary *dict, void *handle, const char *input,
char **poutput, size_t *psize)
{
struct sqlconn *conn = handle;

Return to:

Send suggestions and report system problems to the System administrator.