aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/lib/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/lib/error.c')
-rw-r--r--src/interfaces/ecpg/lib/error.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/lib/error.c b/src/interfaces/ecpg/lib/error.c
index 5aa4b771566..e7e976116b8 100644
--- a/src/interfaces/ecpg/lib/error.c
+++ b/src/interfaces/ecpg/lib/error.c
@@ -7,9 +7,10 @@
#include <sqlca.h>
void
-ECPGraise(int line, int code, const char *str)
+ECPGraise(int line, int code, char *str)
{
sqlca.sqlcode = code;
+
switch (code)
{
case ECPG_NOT_FOUND:
@@ -117,9 +118,13 @@ ECPGraise(int line, int code, const char *str)
"Variable is not a character type in line %d.", line);
break;
- case ECPG_PGSQL:
+ case ECPG_PGSQL:
+ /* strip trailing newline */
+ if (str[strlen(str)-1] == '\n')
+ str[strlen(str)-1] = '\0';
+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
- "Postgres error '%s' in line %d.", str, line);
+ "'%s' in line %d.", str, line);
break;
case ECPG_TRANS:
@@ -134,12 +139,12 @@ ECPGraise(int line, int code, const char *str)
default:
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
- "SQL error #%d in line %d.",code, line);
+ "SQL error #%d in line %d.", code, line);
break;
}
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
-
+
/* free all memory we have allocated for the user */
free_auto_mem();
}