1- /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.40 2002/10/21 13:09:31 meskes Exp $ */
1+ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.41 2003/02/13 13:11:52 meskes Exp $ */
22
33/*
44 * The aim is to get a simpler inteface to the database routines.
@@ -850,6 +850,7 @@ ECPGexecute(struct statement * stmt)
850850{
851851bool status = false;
852852char * copiedquery ;
853+ char * errmsg ,* cmdstat ;
853854PGresult * results ;
854855PGnotify * notify ;
855856struct variable * var ;
@@ -949,9 +950,10 @@ ECPGexecute(struct statement * stmt)
949950
950951if (results == NULL )
951952{
952- ECPGlog ("ECPGexecute line %d: error: %s" ,stmt -> lineno ,
953- PQerrorMessage (stmt -> connection -> connection ));
954- ECPGraise (stmt -> lineno ,ECPG_PGSQL ,PQerrorMessage (stmt -> connection -> connection ));
953+ errmsg = PQerrorMessage (stmt -> connection -> connection );
954+ ECPGlog ("ECPGexecute line %d: error: %s" ,stmt -> lineno ,errmsg );
955+ ECPGraise (stmt -> lineno ,ECPG_PGSQL ,errmsg );
956+ set_backend_err (errmsg ,stmt -> lineno );
955957}
956958else
957959
@@ -961,7 +963,9 @@ ECPGexecute(struct statement * stmt)
961963 */
962964{
963965bool clear_result = TRUE;
964-
966+ errmsg = PQresultErrorMessage (results );
967+ set_backend_err (errmsg ,stmt -> lineno );
968+
965969var = stmt -> outlist ;
966970switch (PQresultStatus (results ))
967971{
@@ -1027,20 +1031,20 @@ ECPGexecute(struct statement * stmt)
10271031break ;
10281032case PGRES_COMMAND_OK :
10291033status = true;
1034+ cmdstat = PQcmdStatus (results );
10301035sqlca .sqlerrd [1 ]= PQoidValue (results );
10311036sqlca .sqlerrd [2 ]= atol (PQcmdTuples (results ));
1032- ECPGlog ("ECPGexecute line %d Ok: %s\n" ,stmt -> lineno ,PQcmdStatus ( results ) );
1033- if (!sqlca .sqlerrd [2 ]&& (!strncmp (PQcmdStatus ( results ) ,"UPDATE" ,6 )
1034- || !strncmp (PQcmdStatus ( results ) ,"INSERT" ,6 )
1035- || !strncmp (PQcmdStatus ( results ) ,"DELETE" ,6 )))
1037+ ECPGlog ("ECPGexecute line %d Ok: %s\n" ,stmt -> lineno ,cmdstat );
1038+ if (!sqlca .sqlerrd [2 ]&& ( !strncmp (cmdstat ,"UPDATE" ,6 )
1039+ || !strncmp (cmdstat ,"INSERT" ,6 )
1040+ || !strncmp (cmdstat ,"DELETE" ,6 )))
10361041ECPGraise (stmt -> lineno ,ECPG_NOT_FOUND ,NULL );
10371042break ;
10381043case PGRES_NONFATAL_ERROR :
10391044case PGRES_FATAL_ERROR :
10401045case PGRES_BAD_RESPONSE :
1041- ECPGlog ("ECPGexecute line %d: Error: %s" ,
1042- stmt -> lineno ,PQerrorMessage (stmt -> connection -> connection ));
1043- ECPGraise (stmt -> lineno ,ECPG_PGSQL ,PQerrorMessage (stmt -> connection -> connection ));
1046+ ECPGlog ("ECPGexecute line %d: Error: %s" ,stmt -> lineno ,errmsg );
1047+ ECPGraise (stmt -> lineno ,ECPG_PGSQL ,errmsg );
10441048status = false;
10451049break ;
10461050case PGRES_COPY_OUT :
@@ -1054,7 +1058,7 @@ ECPGexecute(struct statement * stmt)
10541058default :
10551059ECPGlog ("ECPGexecute line %d: Got something else, postgres error.\n" ,
10561060stmt -> lineno );
1057- ECPGraise (stmt -> lineno ,ECPG_PGSQL ,PQerrorMessage ( stmt -> connection -> connection ) );
1061+ ECPGraise (stmt -> lineno ,ECPG_PGSQL ,errmsg );
10581062status = false;
10591063break ;
10601064}