mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
- Finished major rewrite to use new protocol version
- Really prepare statements - Added more regression tests - Added auto-prepare mode - Use '$n' for positional variables, '?' is still possible via ecpg option - Cleaned up the sources a little bit
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.16 2007/05/31 15:13:05 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.17 2007/08/14 10:01:52 meskes Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -9,7 +9,6 @@
|
||||
#include "extern.h"
|
||||
#include "sqlca.h"
|
||||
|
||||
|
||||
void
|
||||
ECPGraise(int line, int code, const char *sqlstate, const char *str)
|
||||
{
|
||||
@ -196,6 +195,59 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
|
||||
ECPGfree_auto_mem();
|
||||
}
|
||||
|
||||
/* filter out all error codes */
|
||||
bool
|
||||
ECPGcheck_PQresult(PGresult *results, int lineno, PGconn *connection, enum COMPAT_MODE compat)
|
||||
{
|
||||
if (results == NULL)
|
||||
{
|
||||
ECPGlog("ECPGcheck_PQresult line %d: error: %s", lineno, PQerrorMessage(connection));
|
||||
ECPGraise_backend(lineno, NULL, connection, compat);
|
||||
return (false);
|
||||
}
|
||||
|
||||
switch (PQresultStatus(results))
|
||||
{
|
||||
|
||||
case PGRES_TUPLES_OK:
|
||||
return (true);
|
||||
break;
|
||||
case PGRES_EMPTY_QUERY:
|
||||
/* do nothing */
|
||||
ECPGraise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
|
||||
PQclear(results);
|
||||
return (false);
|
||||
break;
|
||||
case PGRES_COMMAND_OK:
|
||||
return (true);
|
||||
break;
|
||||
case PGRES_NONFATAL_ERROR:
|
||||
case PGRES_FATAL_ERROR:
|
||||
case PGRES_BAD_RESPONSE:
|
||||
ECPGlog("ECPGcheck_PQresult line %d: Error: %s", lineno, PQresultErrorMessage(results));
|
||||
ECPGraise_backend(lineno, results, connection, compat);
|
||||
PQclear(results);
|
||||
return (false);
|
||||
break;
|
||||
case PGRES_COPY_OUT:
|
||||
return(true);
|
||||
break;
|
||||
case PGRES_COPY_IN:
|
||||
ECPGlog("ECPGcheck_PQresult line %d: Got PGRES_COPY_IN ... tossing.\n", lineno);
|
||||
PQendcopy(connection);
|
||||
PQclear(results);
|
||||
return(false);
|
||||
break;
|
||||
default:
|
||||
ECPGlog("ECPGcheck_PQresult line %d: Got something else, postgres error.\n",
|
||||
lineno);
|
||||
ECPGraise_backend(lineno, results, connection, compat);
|
||||
PQclear(results);
|
||||
return(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print out an error message */
|
||||
void
|
||||
sqlprint(void)
|
||||
|
Reference in New Issue
Block a user