Skip to content

Commit b78efb6

Browse files
author
Michael Meskes
committed
Make sure each call to ECPGraise is logged.
1 parent 8a52b89 commit b78efb6

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,5 +1116,9 @@ TUe Okt 2 16:09:26 CEST 2001
11161116
Fri Okt 5 08:37:01 CEST 2001
11171117

11181118
- Fixed yet another typo in preproc.y.
1119+
1120+
Fri Okt 5 19:33:46 CEST 2001
1121+
1122+
- Make sure every call to ECPGraise is logged.
11191123
- Set ecpg version to 2.9.0.
11201124
- Set library version to 3.3.0.

src/interfaces/ecpg/lib/data.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.16 2001/10/01 12:02:28 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.17 2001/10/05 17:37:07 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -27,7 +27,6 @@ get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
2727
{
2828
if (*pval != '{')
2929
{
30-
ECPGlog("get_data: data entry does not look like an array in line %d\n", lineno);
3130
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL);
3231
return (false);
3332
}

src/interfaces/ecpg/lib/error.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.10 2001/09/19 14:09:32 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/error.c,v 1.11 2001/10/05 17:37:07 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -89,12 +89,12 @@ ECPGraise(int line, int code, const char *str)
8989

9090
case ECPG_NOT_CONN:
9191
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
92-
"Not connected in line %d.", line);
92+
"Not connected to '%s' in line %d.", str, line);
9393
break;
9494

9595
case ECPG_INVALID_STMT:
9696
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
97-
"Invalid statement name in line %d.", line);
97+
"Invalid statement name %s in line %d.", str, line);
9898
break;
9999

100100
case ECPG_UNKNOWN_DESCRIPTOR:
@@ -151,6 +151,7 @@ ECPGraise(int line, int code, const char *str)
151151
}
152152

153153
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
154+
ECPGlog("raising sqlcode %d in line %d, '%s'.\n", code, line, sqlca.sqlerrm.sqlerrmc);
154155

155156
/* free all memory we have allocated for the user */
156157
free_auto_mem();

src/interfaces/ecpg/lib/execute.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.27 2001/10/02 14:08:28 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.28 2001/10/05 17:37:07 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -182,7 +182,6 @@ create_statement(int lineno, struct connection * connection, struct statement **
182182
/* if variable is NULL, the statement hasn't been prepared */
183183
if (var->pointer == NULL)
184184
{
185-
ECPGlog("create_statement: invalid statement name\n");
186185
ECPGraise(lineno, ECPG_INVALID_STMT, NULL);
187186
free(var);
188187
return false;
@@ -405,7 +404,6 @@ ECPGstore_result(const PGresult *results, int act_field,
405404
*/
406405
if (var->arrsize == 0)
407406
{
408-
ECPGlog("ECPGexecute line %d: variable is not an array\n");
409407
ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL);
410408
return false;
411409
}
@@ -942,7 +940,7 @@ ECPGexecute(struct statement * stmt)
942940

943941
if (ntuples < 1)
944942
{
945-
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
943+
if (ntuples) ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
946944
stmt->lineno, ntuples);
947945
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
948946
status = false;
@@ -957,15 +955,14 @@ ECPGexecute(struct statement * stmt)
957955
PQclear(*resultpp);
958956
*resultpp=results;
959957
clear_result = FALSE;
960-
ECPGlog("ECPGexecute putting result into descriptor '%s'\n", (const char*)var->pointer);
958+
ECPGlog("ECPGexecute putting result (%d tuples) into descriptor '%s'\n", PQntuples(results), (const char*)var->pointer);
961959
}
962960
var = var->next;
963961
}
964962
else for (act_field = 0; act_field < nfields && status; act_field++)
965963
{
966964
if (var == NULL)
967965
{
968-
ECPGlog("ECPGexecute line %d: Too few arguments.\n", stmt->lineno);
969966
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
970967
return (false);
971968
}
@@ -1068,8 +1065,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10681065
if (con == NULL || con->connection == NULL)
10691066
{
10701067
free_statement(stmt);
1071-
ECPGlog("ECPGdo: not connected to %s\n", con->name);
1072-
ECPGraise(lineno, ECPG_NOT_CONN, NULL);
1068+
ECPGraise(lineno, ECPG_NOT_CONN, (con) ? con->name : "<empty>");
10731069
setlocale(LC_NUMERIC, oldlocale);
10741070
free(oldlocale);
10751071
return false;

src/interfaces/ecpg/lib/memory.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.5 2001/09/19 14:09:32 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/memory.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -14,7 +14,6 @@ ecpg_alloc(long size, int lineno)
1414

1515
if (!new)
1616
{
17-
ECPGlog("out of memory\n");
1817
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
1918
return NULL;
2019
}
@@ -30,7 +29,6 @@ ecpg_strdup(const char *string, int lineno)
3029

3130
if (!new)
3231
{
33-
ECPGlog("out of memory\n");
3432
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
3533
return NULL;
3634
}

src/interfaces/ecpg/lib/misc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.5 2001/09/19 14:09:32 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/misc.c,v 1.6 2001/10/05 17:37:07 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -54,8 +54,7 @@ ECPGstatus(int lineno, const char *connection_name)
5454
/* are we connected? */
5555
if (con->connection == NULL)
5656
{
57-
ECPGlog("ECPGdo: not connected to %s\n", con->name);
58-
ECPGraise(lineno, ECPG_NOT_CONN, NULL);
57+
ECPGraise(lineno, ECPG_NOT_CONN, con->name);
5958
return false;
6059
}
6160

src/interfaces/ecpg/lib/prepare.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.7 2001/09/19 14:09:32 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/prepare.c,v 1.8 2001/10/05 17:37:07 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -125,7 +125,6 @@ ECPGdeallocate(int lineno, char *name)
125125
free(this);
126126
return true;
127127
}
128-
ECPGlog("deallocate_prepare: invalid statement name %s\n", name);
129128
ECPGraise(lineno, ECPG_INVALID_STMT, name);
130129
return false;
131130
}

0 commit comments

Comments
 (0)