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

Commit339a5bb

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent95563e7 commit339a5bb

File tree

14 files changed

+575
-73
lines changed

14 files changed

+575
-73
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,5 +933,12 @@ Mon Sep 4 14:10:38 PDT 2000
933933
Mon Sep 18 13:55:11 PDT 2000
934934

935935
- Added int8 support based on a patch by Martijn Schoemaker <martijn@osp.nl>
936+
937+
Mit Sep 20 12:40:27 PDT 2000
938+
939+
- Added patch by Christof Petig <christof.petig@wtal.de> to process
940+
backend NOTICEs.
941+
- Added patch by Christof Petig <christof.petig@wtal.de> to cache
942+
type information.
936943
- Set ecpg version to 2.8.0.
937944
- Set library version to 3.2.0.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,19 @@
4343
#defineECPG_TRANS-401
4444
#defineECPG_CONNECT-402
4545

46+
/* backend notices, starting at 600 */
47+
#defineECPG_NOTICE_UNRECOGNIZED -600
48+
/* NOTICE: (transaction aborted): queries ignored until END */
49+
/* NOTICE: current transaction is aborted, queries ignored until end of transaction block */
50+
#defineECPG_NOTICE_QUERY_IGNORED -601
51+
/* NOTICE: PerformPortalClose: portal "*" not found */
52+
#defineECPG_NOTICE_UNKNOWN_PORTAL -602
53+
/* NOTICE: BEGIN: already a transaction in progress */
54+
#defineECPG_NOTICE_IN_TRANSACTION -603
55+
/* NOTICE: AbortTransaction and not in in-progress state */
56+
/* NOTICE: COMMIT: no transaction in progress */
57+
#defineECPG_NOTICE_NO_TRANSACTION -604
58+
/* NOTICE: BlankPortalAssignName: portal * already exists */
59+
#defineECPG_NOTICE_PORTAL_EXISTS -605
60+
4661
#endif/* !_ECPG_ERROR_H */

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,22 @@ extern"C"
2222
longsqlerrd[6];
2323
/* Element 0: empty*/
2424
/* 1: OID of processed tuple if applicable*/
25-
/* 2: number of rows processed*/
26-
/* after an INSERT, UPDATE or */
27-
/* DELETE statement*/
25+
/* 2: number of rows processed*/
26+
/* after an INSERT, UPDATE or*/
27+
/* DELETE statement*/
2828
/* 3: empty*/
2929
/* 4: empty*/
3030
/* 5: empty*/
3131
charsqlwarn[8];
32-
/* Element 0: set to 'W' if at least one other is 'W' */
33-
/* 1: if 'W' at least one character string */
34-
/* value was truncated when it was */
35-
/* stored into a host variable. */
36-
/* 2: empty */
37-
/* 3: empty */
38-
/* 4: empty */
39-
/* 5: empty */
40-
/* 6: empty */
41-
/* 7: empty */
32+
/* Element 0: set to 'W' if at least one other is 'W' */
33+
/* 1: if 'W' at least one character string */
34+
/* value was truncated when it was */
35+
/* stored into a host variable. */
36+
/* 2: if 'W' a (hopefully) non-fatal notice occured *//* 3: empty */
37+
/* 4: empty*/
38+
/* 5: empty*/
39+
/* 6: empty*/
40+
/* 7: empty*/
4241

4342
charsqlext[8];
4443
};

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

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ecpg_finish(struct connection * act)
2727
{
2828
if (act!=NULL)
2929
{
30+
structECPGtype_information_cache*cache,*ptr;
31+
3032
ECPGlog("ecpg_finish: finishing %s.\n",act->name);
3133
PQfinish(act->connection);
3234

@@ -45,6 +47,7 @@ ecpg_finish(struct connection * act)
4547
if (actual_connection==act)
4648
actual_connection=all_connections;
4749

50+
for (cache=act->cache_head;cache;ptr=cache,cache=cache->next,free(ptr));
4851
free(act->name);
4952
free(act);
5053
}
@@ -107,6 +110,120 @@ ECPGsetconn(int lineno, const char *connection_name)
107110
return true;
108111
}
109112

113+
staticvoid
114+
ECPGnoticeProcessor_raise(intcode,constchar*message)
115+
{
116+
sqlca.sqlcode=code;
117+
strncpy(sqlca.sqlerrm.sqlerrmc,message,sizeof(sqlca.sqlerrm.sqlerrmc));
118+
sqlca.sqlerrm.sqlerrmc[sizeof(sqlca.sqlerrm.sqlerrmc)-1]=0;
119+
sqlca.sqlerrm.sqlerrml=strlen(sqlca.sqlerrm.sqlerrmc);
120+
121+
// remove trailing newline
122+
if (sqlca.sqlerrm.sqlerrml
123+
&&sqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml-1]=='\n')
124+
{
125+
sqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml-1]=0;
126+
sqlca.sqlerrm.sqlerrml--;
127+
}
128+
129+
ECPGlog("raising sqlcode %d\n",code);
130+
}
131+
132+
/*
133+
* I know this is a mess, but we can't redesign the backend
134+
*/
135+
136+
staticvoid
137+
ECPGnoticeProcessor(void*arg,constchar*message)
138+
{
139+
/* these notices raise an error */
140+
if (strncmp(message,"NOTICE: ",8))
141+
{
142+
ECPGlog("ECPGnoticeProcessor: strange notice '%s'\n",message);
143+
ECPGnoticeProcessor_raise(ECPG_NOTICE_UNRECOGNIZED,message);
144+
return;
145+
}
146+
147+
message+=8;
148+
while (*message==' ')message++;
149+
ECPGlog("NOTICE: %s",message);
150+
151+
/* NOTICE: (transaction aborted): queries ignored until END */
152+
/* NOTICE: current transaction is aborted, queries ignored until end of transaction block */
153+
if (strstr(message,"queries ignored")&&strstr(message,"transaction")
154+
&&strstr(message,"aborted"))
155+
{
156+
ECPGnoticeProcessor_raise(ECPG_NOTICE_QUERY_IGNORED,message);
157+
return;
158+
}
159+
160+
/* NOTICE: PerformPortalClose: portal "*" not found */
161+
if (!strncmp(message,"PerformPortalClose: portal",26)
162+
&&strstr(message+26,"not found"))
163+
{
164+
ECPGnoticeProcessor_raise(ECPG_NOTICE_UNKNOWN_PORTAL,message);
165+
return;
166+
}
167+
168+
/* NOTICE: BEGIN: already a transaction in progress */
169+
if (!strncmp(message,"BEGIN: already a transaction in progress",40))
170+
{
171+
ECPGnoticeProcessor_raise(ECPG_NOTICE_IN_TRANSACTION,message);
172+
return;
173+
}
174+
175+
/* NOTICE: AbortTransaction and not in in-progress state */
176+
/* NOTICE: COMMIT: no transaction in progress */
177+
/* NOTICE: ROLLBACK: no transaction in progress */
178+
if (!strncmp(message,"AbortTransaction and not in in-progress state",45)
179+
|| !strncmp(message,"COMMIT: no transaction in progress",34)
180+
|| !strncmp(message,"ROLLBACK: no transaction in progress",36))
181+
{
182+
ECPGnoticeProcessor_raise(ECPG_NOTICE_NO_TRANSACTION,message);
183+
return;
184+
}
185+
186+
/* NOTICE: BlankPortalAssignName: portal * already exists */
187+
if (!strncmp(message,"BlankPortalAssignName: portal",29)
188+
&&strstr(message+29,"already exists"))
189+
{
190+
ECPGnoticeProcessor_raise(ECPG_NOTICE_PORTAL_EXISTS,message);
191+
return;
192+
}
193+
194+
/* these are harmless - do nothing */
195+
/* NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index '*' for table '*' */
196+
/* NOTICE: ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s) */
197+
/* NOTICE: CREATE TABLE will create implicit sequence '*' for SERIAL column '*.*' */
198+
/* NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) */
199+
if ((!strncmp(message,"CREATE TABLE",12)|| !strncmp(message,"ALTER TABLE",11))
200+
&&strstr(message+11,"will create implicit"))
201+
return;
202+
203+
/* NOTICE: QUERY PLAN: */
204+
if (!strncmp(message,"QUERY PLAN:",11))// do we really see these?
205+
return;
206+
207+
/* NOTICE: DROP TABLE implicitly drops referential integrity trigger from table "*" */
208+
if (!strncmp(message,"DROP TABLE implicitly drops",27))
209+
return;
210+
211+
/* NOTICE: Caution: DROP INDEX cannot be rolled back, so don't abort now */
212+
if (strstr(message,"cannot be rolled back"))
213+
return;
214+
215+
/* these and other unmentioned should set sqlca.sqlwarn[2] */
216+
/* NOTICE: The ':' operator is deprecated. Use exp(x) instead. */
217+
/* NOTICE: Rel *: Uninitialized page 0 - fixing */
218+
/* NOTICE: PortalHeapMemoryFree: * not in alloc set! */
219+
/* NOTICE: Too old parent tuple found - can't continue vc_repair_frag */
220+
/* NOTICE: identifier "*" will be truncated to "*" */
221+
/* NOTICE: InvalidateSharedInvalid: cache state reset */
222+
/* NOTICE: RegisterSharedInvalid: SI buffer overflow */
223+
sqlca.sqlwarn[2]='W';
224+
sqlca.sqlwarn[0]='W';
225+
}
226+
110227
bool
111228
ECPGconnect(intlineno,constchar*dbname,constchar*user,constchar*passwd,constchar*connection_name,intautocommit)
112229
{
@@ -119,12 +236,14 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
119236

120237
if (dbname==NULL&&connection_name==NULL)
121238
connection_name="DEFAULT";
122-
239+
123240
/* add connection to our list */
124241
if (connection_name!=NULL)
125242
this->name=ecpg_strdup(connection_name,lineno);
126243
else
127244
this->name=ecpg_strdup(dbname,lineno);
245+
246+
this->cache_head=NULL;
128247

129248
if (all_connections==NULL)
130249
this->next=NULL;
@@ -147,6 +266,8 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
147266

148267
this->committed= true;
149268
this->autocommit=autocommit;
269+
270+
PQsetNoticeProcessor(this->connection,&ECPGnoticeProcessor,(void*)this);
150271

151272
return true;
152273
}

‎src/interfaces/ecpg/lib/descriptor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ ECPGdeallocate_desc(int line, const char *name)
302302
bool
303303
ECPGallocate_desc(intline,constchar*name)
304304
{
305-
structdescriptor*new= (structdescriptor*)malloc(sizeof(structdescriptor));
305+
structdescriptor*new= (structdescriptor*)ecpg_alloc(sizeof(structdescriptor),line);
306306

307307
new->next=all_descriptors;
308-
new->name=malloc(strlen(name)+1);
308+
new->name=ecpg_alloc(strlen(name)+1,line);
309309
new->result=PQmakeEmptyPGresult(NULL,0);
310310
strcpy(new->name,name);
311311
all_descriptors=new;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp