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 $ */
2
2
3
3
/*
4
4
* The aim is to get a simpler inteface to the database routines.
@@ -850,6 +850,7 @@ ECPGexecute(struct statement * stmt)
850
850
{
851
851
bool status = false;
852
852
char * copiedquery ;
853
+ char * errmsg , * cmdstat ;
853
854
PGresult * results ;
854
855
PGnotify * notify ;
855
856
struct variable * var ;
@@ -949,9 +950,10 @@ ECPGexecute(struct statement * stmt)
949
950
950
951
if (results == NULL )
951
952
{
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 );
955
957
}
956
958
else
957
959
@@ -961,7 +963,9 @@ ECPGexecute(struct statement * stmt)
961
963
*/
962
964
{
963
965
bool clear_result = TRUE;
964
-
966
+ errmsg = PQresultErrorMessage (results );
967
+ set_backend_err (errmsg , stmt -> lineno );
968
+
965
969
var = stmt -> outlist ;
966
970
switch (PQresultStatus (results ))
967
971
{
@@ -1027,20 +1031,20 @@ ECPGexecute(struct statement * stmt)
1027
1031
break ;
1028
1032
case PGRES_COMMAND_OK :
1029
1033
status = true;
1034
+ cmdstat = PQcmdStatus (results );
1030
1035
sqlca .sqlerrd [1 ] = PQoidValue (results );
1031
1036
sqlca .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 )))
1036
1041
ECPGraise (stmt -> lineno , ECPG_NOT_FOUND , NULL );
1037
1042
break ;
1038
1043
case PGRES_NONFATAL_ERROR :
1039
1044
case PGRES_FATAL_ERROR :
1040
1045
case 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 );
1044
1048
status = false;
1045
1049
break ;
1046
1050
case PGRES_COPY_OUT :
@@ -1054,7 +1058,7 @@ ECPGexecute(struct statement * stmt)
1054
1058
default :
1055
1059
ECPGlog ("ECPGexecute line %d: Got something else, postgres error.\n" ,
1056
1060
stmt -> lineno );
1057
- ECPGraise (stmt -> lineno , ECPG_PGSQL , PQerrorMessage ( stmt -> connection -> connection ) );
1061
+ ECPGraise (stmt -> lineno , ECPG_PGSQL , errmsg );
1058
1062
status = false;
1059
1063
break ;
1060
1064
}
0 commit comments