Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit42df5e3

Browse files
author
Michael Meskes
committed
Started to create different error codes for different backend messages.
1 parent9117e55 commit42df5e3

File tree

7 files changed

+34
-43
lines changed

7 files changed

+34
-43
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,16 @@ Wed Jul 9 11:45:02 CEST 2003
15691569
- Made all Informix functions honor Informix NULLs.
15701570
- Extended compatibility functions for INFORMIX handling of DECLARE
15711571
statement to work with indicators.
1572+
1573+
Mon Jul 14 09:34:04 CEST 2003
1574+
1575+
- Synced preproc.y with gram.y
1576+
- Init sqlca in ECPGprepare().
1577+
- Added CLOSE DATABASE for Informix compatibility.
1578+
1579+
Tue Jul 15 14:28:53 CEST 2003
1580+
1581+
_ Started to add error codes for backend error messages.
15721582
- Set ecpg version to 3.0.0
15731583
- Set ecpg library to 4.0.0
15741584
- Set pgtypes library to 1.0.0

‎src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.11 2003/07/08 07:13:48 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.12 2003/07/15 12:38:38 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -68,7 +68,6 @@ ecpg_finish(struct connection * act)
6868
structECPGtype_information_cache*cache,
6969
*ptr;
7070

71-
ECPGlog("ecpg_finish: finishing %s.\n",act->name);
7271
PQfinish(act->connection);
7372

7473
/* no need to lock connections_mutex - we're always called
@@ -90,6 +89,8 @@ ecpg_finish(struct connection * act)
9089
if (actual_connection==act)
9190
actual_connection=all_connections;
9291

92+
ECPGlog("ecpg_finish: Connection %s closed.\n",act->name);
93+
9394
for (cache=act->cache_head;cache;ptr=cache,cache=cache->next,ECPGfree(ptr));
9495
ECPGfree(act->name);
9596
ECPGfree(act);
@@ -481,10 +482,9 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
481482

482483
if (PQstatus(this->connection)==CONNECTION_BAD)
483484
{
484-
constchar*errmsg=PQerrorMessage(this->connection);
485-
char*db=realname ?realname :"<DEFAULT>";
485+
constchar*errmsg=PQerrorMessage(this->connection);
486+
char*db=realname ?realname :"<DEFAULT>";
486487

487-
set_backend_err(errmsg,lineno);
488488
ecpg_finish(this);
489489
#ifdefUSE_THREADS
490490
pthread_mutex_unlock(&connections_mutex);

‎src/interfaces/ecpg/ecpglib/error.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.2 2003/06/1504:07:58 momjian Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.3 2003/07/1512:38:38 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -11,10 +11,6 @@
1111
#include"extern.h"
1212
#include"sqlca.h"
1313

14-
/* This should hold the back-end error message from
15-
* the last back-end operation. */
16-
staticchar*ECPGerr;
17-
1814
void
1915
ECPGraise(intline,intcode,constchar*str)
2016
{
@@ -142,6 +138,11 @@ ECPGraise(int line, int code, const char *str)
142138
slen--;
143139
snprintf(sqlca->sqlerrm.sqlerrmc,sizeof(sqlca->sqlerrm.sqlerrmc),
144140
"'%.*s' in line %d.",slen,str,line);
141+
if (strncmp(str,"ERROR: Cannot insert a duplicate key",strlen("ERROR: Cannot insert a duplicate key"))==0)
142+
sqlca->sqlcode=ECPG_DUPLICATE_KEY;
143+
elseif (strncmp(str,"ERROR: More than one tuple returned by a subselect",strlen("ERROR: More than one tuple returned by a subselect"))==0)
144+
sqlca->sqlcode=ECPG_SUBSELECT_NOT_ONE;
145+
145146
break;
146147
}
147148

@@ -168,29 +169,6 @@ ECPGraise(int line, int code, const char *str)
168169
ECPGfree_auto_mem();
169170
}
170171

171-
/* Set the error message string from the backend */
172-
void
173-
set_backend_err(constchar*err,intlineno)
174-
{
175-
if (ECPGerr)
176-
ECPGfree(ECPGerr);
177-
178-
if (!err)
179-
{
180-
ECPGerr=NULL;
181-
return;
182-
}
183-
184-
ECPGerr=ECPGstrdup(err,lineno);
185-
}
186-
187-
/* Retrieve the error message from the backend. */
188-
char*
189-
ECPGerrmsg(void)
190-
{
191-
returnECPGerr;
192-
}
193-
194172
/* print out an error message */
195173
void
196174
sqlprint(void)

‎src/interfaces/ecpg/ecpglib/execute.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/ecpglib/execute.c,v 1.18 2003/07/08 12:11:29 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.19 2003/07/15 12:38:38 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -1131,7 +1131,6 @@ ECPGexecute(struct statement * stmt)
11311131
errmsg=PQerrorMessage(stmt->connection->connection);
11321132
ECPGlog("ECPGexecute line %d: error: %s",stmt->lineno,errmsg);
11331133
ECPGraise(stmt->lineno,ECPG_PGSQL,errmsg);
1134-
set_backend_err(errmsg,stmt->lineno);
11351134
}
11361135
else
11371136

@@ -1144,7 +1143,6 @@ ECPGexecute(struct statement * stmt)
11441143
structsqlca_t*sqlca=ECPGget_sqlca();
11451144

11461145
errmsg=PQresultErrorMessage(results);
1147-
set_backend_err(errmsg,stmt->lineno);
11481146

11491147
var=stmt->outlist;
11501148
switch (PQresultStatus(results))

‎src/interfaces/ecpg/ecpglib/extern.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ enum COMPAT_MODE { ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFO
1010

1111
/* Here are some methods used by the lib. */
1212

13-
/* Stores the backend error message for client access */
14-
voidset_backend_err(constchar*err,intlineon);
15-
16-
/* Store and retrieve the backend error message for client access */
17-
voidset_backend_err(constchar*err,intlineon);
18-
char*ECPGerrmsg(void);
19-
2013
/* Returns a pointer to a string containing a simple type name. */
2114
voidECPGadd_mem(void*ptr,intlineno);
2215

‎src/interfaces/ecpg/include/ecpgerrno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#defineECPG_PGSQL-400
4848
#defineECPG_TRANS-401
4949
#defineECPG_CONNECT-402
50+
#defineECPG_DUPLICATE_KEY-403
51+
#defineECPG_SUBSELECT_NOT_ONE-404
5052

5153
/* backend WARNINGs, starting at 600 */
5254
#defineECPG_WARNING_UNRECOGNIZED -600

‎src/interfaces/ecpg/test/test_informix.pgc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ int main()
1717

1818
rsetnull(CDECIMALTYPE, (char *)&j);
1919
$insert into test (i, j) values (7, :j);
20+
$commit;
21+
22+
$insert into test (i, j) values (7, 2);
23+
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
24+
if (sqlca.sqlcode != 0) $rollback;
25+
2026
$insert into test (i, j) values (:i, 1);
2127

28+
$select i from test where j=(select j from test);
29+
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
30+
if (sqlca.sqlcode != 0) $rollback;
31+
2232
$declare c cursor for select * from test where i <= :i;
2333
openit();
2434

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp