aboutsummaryrefslogtreecommitdiff
path: root/src/pgsql.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pgsql.c')
-rw-r--r--src/pgsql.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/pgsql.c b/src/pgsql.c
index 8c7699b..44b1fa6 100644
--- a/src/pgsql.c
+++ b/src/pgsql.c
@@ -11,10 +11,9 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -50,8 +49,12 @@ s_pgsql_connect (char *hostname, int port,
snprintf(buf, sizeof buf, "%d", port);
pgconn = PQsetdbLogin(hostname, buf, NULL, NULL, dbname, user, pass);
- if (PQstatus(pgconn) == CONNECTION_BAD)
- return SCM_BOOL_F;
+ if (PQstatus(pgconn) == CONNECTION_BAD) {
+ SCM args = scm_list_2(scm_makfrom0str("Cannot connect to the database"),
+ scm_makfrom0str(PQerrorMessage(pgconn)));
+ PQfinish(pgconn);
+ scm_throw(gsql_error, args);
+ }
smob = sql_connect_create("pgsql");
conn = (struct sql_connect *)SCM_CDR(smob);
@@ -109,10 +112,10 @@ s_pgsql_query(struct sql_connect *conn, char *query)
ExecStatusType stat;
res = PQexec(pgconn, query);
- if (!res)
- scm_misc_error("s_mgsql_query",
- "pgSQL error: ~S",
- SCM_LIST1(scm_makfrom0str(PQerrorMessage(pgconn))));
+ if (!res)
+ scm_throw(gsql_error,
+ scm_list_2(scm_makfrom0str("Error executing PostgreSQL query"),
+ scm_makfrom0str(PQerrorMessage(pgconn))));
stat = PQresultStatus(res);
@@ -127,9 +130,8 @@ s_pgsql_query(struct sql_connect *conn, char *query)
PQclear(res);
break;
default:
- scm_misc_error("s_mgsql_query",
- "pgSQL error: ~S",
- SCM_LIST1(scm_makfrom0str(PQresStatus(stat))));
+ scm_throw(gsql_error, scm_list_2(scm_makfrom0str("PostgreSQL error"),
+ scm_makfrom0str(PQresStatus(stat))));
}
return cell;

Return to:

Send suggestions and report system problems to the System administrator.