- Made all Informix functions honor Informix NULLs.
- Extended compatibility functions for INFORMIX handling of DECLARE
statement to work with indicators.
+
+Mon Jul 14 09:34:04 CEST 2003
+
+ - Synced preproc.y with gram.y
+ - Init sqlca in ECPGprepare().
+ - Added CLOSE DATABASE for Informix compatibility.
+
+Tue Jul 15 14:28:53 CEST 2003
+
+ _ Started to add error codes for backend error messages.
- Set ecpg version to 3.0.0
- Set ecpg library to 4.0.0
- Set pgtypes library to 1.0.0
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.11 2003/07/08 07:13:48 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.12 2003/07/15 12:38:38 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
struct ECPGtype_information_cache *cache,
*ptr;
- ECPGlog("ecpg_finish: finishing %s.\n", act->name);
PQfinish(act->connection);
/* no need to lock connections_mutex - we're always called
if (actual_connection == act)
actual_connection = all_connections;
+ ECPGlog("ecpg_finish: Connection %s closed.\n", act->name);
+
for (cache = act->cache_head; cache; ptr = cache, cache = cache->next, ECPGfree(ptr));
ECPGfree(act->name);
ECPGfree(act);
if (PQstatus(this->connection) == CONNECTION_BAD)
{
- const char *errmsg = PQerrorMessage(this->connection);
- char *db = realname ? realname : "<DEFAULT>";
+ const char *errmsg = PQerrorMessage(this->connection);
+ char *db = realname ? realname : "<DEFAULT>";
- set_backend_err(errmsg, lineno);
ecpg_finish(this);
#ifdef USE_THREADS
pthread_mutex_unlock(&connections_mutex);
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.2 2003/06/15 04:07:58 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.3 2003/07/15 12:38:38 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
#include "extern.h"
#include "sqlca.h"
-/* This should hold the back-end error message from
- * the last back-end operation. */
-static char *ECPGerr;
-
void
ECPGraise(int line, int code, const char *str)
{
slen--;
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
"'%.*s' in line %d.", slen, str, line);
+ if (strncmp(str, "ERROR: Cannot insert a duplicate key", strlen("ERROR: Cannot insert a duplicate key")) == 0)
+ sqlca->sqlcode = ECPG_DUPLICATE_KEY;
+ else if (strncmp(str, "ERROR: More than one tuple returned by a subselect", strlen("ERROR: More than one tuple returned by a subselect")) == 0)
+ sqlca->sqlcode = ECPG_SUBSELECT_NOT_ONE;
+
break;
}
ECPGfree_auto_mem();
}
-/* Set the error message string from the backend */
-void
-set_backend_err(const char *err, int lineno)
-{
- if (ECPGerr)
- ECPGfree(ECPGerr);
-
- if (!err)
- {
- ECPGerr = NULL;
- return;
- }
-
- ECPGerr = ECPGstrdup(err, lineno);
-}
-
-/* Retrieve the error message from the backend. */
-char *
-ECPGerrmsg(void)
-{
- return ECPGerr;
-}
-
/* print out an error message */
void
sqlprint(void)
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.18 2003/07/08 12:11:29 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.19 2003/07/15 12:38:38 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
errmsg = PQerrorMessage(stmt->connection->connection);
ECPGlog("ECPGexecute line %d: error: %s", stmt->lineno, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
- set_backend_err(errmsg, stmt->lineno);
}
else
struct sqlca_t *sqlca = ECPGget_sqlca();
errmsg = PQresultErrorMessage(results);
- set_backend_err(errmsg, stmt->lineno);
var = stmt->outlist;
switch (PQresultStatus(results))
/* Here are some methods used by the lib. */
-/* Stores the backend error message for client access */
-void set_backend_err(const char *err, int lineon);
-
-/* Store and retrieve the backend error message for client access */
-void set_backend_err(const char *err, int lineon);
-char *ECPGerrmsg(void);
-
/* Returns a pointer to a string containing a simple type name. */
void ECPGadd_mem(void *ptr, int lineno);
#define ECPG_PGSQL -400
#define ECPG_TRANS -401
#define ECPG_CONNECT -402
+#define ECPG_DUPLICATE_KEY -403
+#define ECPG_SUBSELECT_NOT_ONE -404
/* backend WARNINGs, starting at 600 */
#define ECPG_WARNING_UNRECOGNIZED -600
rsetnull(CDECIMALTYPE, (char *)&j);
$insert into test (i, j) values (7, :j);
+ $commit;
+
+ $insert into test (i, j) values (7, 2);
+ printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+ if (sqlca.sqlcode != 0) $rollback;
+
$insert into test (i, j) values (:i, 1);
+ $select i from test where j=(select j from test);
+ printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+ if (sqlca.sqlcode != 0) $rollback;
+
$declare c cursor for select * from test where i <= :i;
openit();