summaryrefslogtreecommitdiffabout
path: root/src/pgsql.c
authorSergey Poznyakoff <gray@gnu.org.ua>2005-06-26 10:38:26 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2005-06-26 10:38:26 (GMT)
commit4987cf3134f116d1881602141ccc5ee7d572b8de (patch) (side-by-side diff)
treea86f7135fd97098f6d98aeeabe0799e20615d91c /src/pgsql.c
parentd47c213bb55adbe961c54242c642c2d1b7c3ec6c (diff)
downloadgamma-4987cf3134f116d1881602141ccc5ee7d572b8de.tar.gz
gamma-4987cf3134f116d1881602141ccc5ee7d572b8de.tar.bz2
Throw gsql-error, instead of misc-error, on failure
Diffstat (limited to 'src/pgsql.c') (more/less context) (ignore whitespace changes)
-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.