aboutsummaryrefslogtreecommitdiff
path: root/src/gsql_conn.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-04-14 12:46:44 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-04-14 12:46:44 +0300
commit302a74e565999792d3cac79df23ee93b01e49f52 (patch)
tree0d6b456092fb092ff71a46d2e23557b3955a9fb6 /src/gsql_conn.c
parent391b9afdd48db47f95567dbf1c3c9d2cc1029415 (diff)
downloadgamma-302a74e565999792d3cac79df23ee93b01e49f52.tar.gz
gamma-302a74e565999792d3cac79df23ee93b01e49f52.tar.bz2
Upgrade gint version.
* gint: Upgrade. * src/Makefile.am: Initialize BUILT_SOURCES. * src/gamma-expat.c: Use lower-case names for parameters to SCM interfaces. Improve docstrings. * src/gsql_conn.c: Likewise. * src/syslog-port.c: Likewise. * src/syslog.c: Likewise.
Diffstat (limited to 'src/gsql_conn.c')
-rw-r--r--src/gsql_conn.c76
1 files changed, 55 insertions, 21 deletions
diff --git a/src/gsql_conn.c b/src/gsql_conn.c
index 86bf926..4d53a03 100644
--- a/src/gsql_conn.c
+++ b/src/gsql_conn.c
@@ -135,8 +135,35 @@ gamma_cvt_iface(SCM inval, void *outval, const char *func_name)
SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0,
- (SCM PARAM),
- "Connect to a database.")
+ (SCM param),
+"Connect to a database. Take connection parameters from @var{param}, "
+"which must be a list of conses. In each cons, the @samp{car} contains "
+"a @dfn{key} identifying the parameter, and the @samp{cdr} supplies the "
+"value for that parameter.\n"
+"\n"
+"Valid keys are:\n"
+"@table @asis\n"
+"@item #:iface\n"
+"Defines the type of the @acronym{SQL} interface (either @samp{mysql} or "
+"@samp{postgres}.\n"
+"@item #:host\n"
+"Server host name.\n"
+"@item #:port\n"
+"Port number on @samp{#:host}.\n"
+"@item #:socket\n"
+"Socket path, if the server is listening on a UNIX socket. Either\n"
+"@samp{#:port} or @samp{#:socket} may be given, but not both.\n"
+"@item #:user\n"
+"Sets the @acronym{SQL} user name.\n"
+"@item #:pass\n"
+"Sets the password for @samp{#:user}\n"
+"@item #:ssl-cert\n"
+"Full pathname of the @acronym{SSL} certificate to use (MySQL only).\n"
+"@item #:config-file\n"
+"Read missing parameters from the specified file (MySQL only).\n"
+"@item #:config-group\n"
+"Read the specified group in the config file (MySQL only).\n"
+"@end table\n")
#define FUNC_NAME s_sql_open_connection
{
int iface;
@@ -148,44 +175,51 @@ SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0,
SCM smob;
- SCM_ASSERT(scm_is_pair(PARAM), PARAM, SCM_ARG1, FUNC_NAME);
- gamma_parmlist_parse (PARAM, dcltab,
+ SCM_ASSERT(scm_is_pair(param), param, SCM_ARG1, FUNC_NAME);
+ gamma_parmlist_parse (param, dcltab,
GAMMA_PARMLIST_IGNORE_UNKNOWN, FUNC_NAME);
- smob = sql_iftab[iface].connect(PARAM, FUNC_NAME);
+ smob = sql_iftab[iface].connect(param, FUNC_NAME);
return smob;
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (sql_close_connection, "sql-close-connection", 1, 0, 0,
- (SCM CONN),
- "Close connection to a database.")
+ (SCM conn),
+ "Close connection to a database.")
#define FUNC_NAME s_sql_close_connection
{
- struct sql_connect *conn;
- SCM_ASSERT(scm_is_sql_connect(CONN), CONN, SCM_ARG1, FUNC_NAME);
- conn = (struct sql_connect *)SCM_CDR(CONN);
- sql_iftab[conn->iface].close(conn);
+ struct sql_connect *cp;
+ SCM_ASSERT(scm_is_sql_connect(conn), conn, SCM_ARG1, FUNC_NAME);
+ cp = (struct sql_connect *)SCM_CDR(conn);
+ sql_iftab[cp->iface].close(cp);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
SCM_DEFINE_PUBLIC (sql_query, "sql-query", 2, 0, 0,
- (SCM CONN, SCM QUERY),
- "Run an SQL query")
+ (SCM conn, SCM query),
+"Send the SQL query @var{query} to the server using connection @var{conn} \
+and return the result.\n\
+If @var{query} is a @samp{SELECT}, or similar query, returning tuples, the \
+return value is a list of rows. Each row is a list of values, one for each \
+column. All values are returned as strings. NULL values are returned as \
+@samp{#f}.\n\n\
+If @var{query} is an @samp{UPDATE} (or a similar query), @code{sql-query} \
+returns number of rows affected by the query.\n")
#define FUNC_NAME s_sql_query
{
- struct sql_connect *conn;
- char *query;
+ struct sql_connect *conn_ptr;
+ char *query_ptr;
SCM ret;
- SCM_ASSERT(scm_is_sql_connect(CONN), CONN, SCM_ARG1, FUNC_NAME);
- SCM_ASSERT(scm_is_string(QUERY), QUERY, SCM_ARG2, FUNC_NAME);
- conn = (struct sql_connect *)SCM_CDR(CONN);
- query = scm_to_locale_string(QUERY);
- ret = sql_iftab[conn->iface].query(conn, query);
- free(query);
+ SCM_ASSERT(scm_is_sql_connect(conn), conn, SCM_ARG1, FUNC_NAME);
+ SCM_ASSERT(scm_is_string(query), query, SCM_ARG2, FUNC_NAME);
+ conn_ptr = (struct sql_connect *)SCM_CDR(conn);
+ query_ptr = scm_to_locale_string(query);
+ ret = sql_iftab[conn_ptr->iface].query(conn_ptr, query_ptr);
+ free(query_ptr);
return ret;
}
#undef FUNC_NAME

Return to:

Send suggestions and report system problems to the System administrator.