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

Commitfa0dc92

Browse files
author
Michael Meskes
committed
- Fixed segfault in ecpg when using an array element.
- Free all memory in auto-prepare mode.
1 parent8d36372 commitfa0dc92

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,3 +2301,10 @@ Tue, 15 Jan 2008 11:26:14 +0100
23012301
- Set compat library version to 3.0.
23022302
- Set ecpg library version to 6.0.
23032303
- Set ecpg version to 4.4.
2304+
2305+
Wed, 06 Feb 2008 09:04:48 +0100
2306+
2307+
- Fixed segfault in ecpg when using an array element.
2308+
- Free all memory in auto-prepare mode.
2309+
2310+

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.75 2008/01/15 10:31:47 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.76 2008/02/07 11:09:12 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -1489,7 +1489,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
14891489
*/
14901490
if (statement_type==ECPGst_prepnormal)
14911491
{
1492-
if (!ecpg_auto_prepare(lineno,connection_name,questionmarks,&prepname,query))
1492+
if (!ecpg_auto_prepare(lineno,connection_name,compat,questionmarks,&prepname,query))
14931493
return (false);
14941494

14951495
/*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.33 2008/01/15 10:31:47 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.34 2008/02/07 11:09:12 meskes Exp $ */
22

33
#ifndef_ECPG_LIB_EXTERN_H
44
#define_ECPG_LIB_EXTERN_H
@@ -146,7 +146,7 @@ voidecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
146146
char*ecpg_prepared(constchar*,structconnection*,int);
147147
boolecpg_deallocate_all_conn(intlineno,enumCOMPAT_MODEc,structconnection*conn);
148148
voidecpg_log(constchar*format,...);
149-
boolecpg_auto_prepare(int,constchar*,constint,char**,constchar*);
149+
boolecpg_auto_prepare(int,constchar*,int,constint,char**,constchar*);
150150
voidecpg_init_sqlca(structsqlca_t*sqlca);
151151

152152
/* SQLSTATE values generated or processed by ecpglib (intentionally

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.25 2007/11/15 22:25:17 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.26 2008/02/07 11:09:13 meskes Exp $ */
22

33
#definePOSTGRES_ECPG_INTERNAL
44
#include"postgres_fe.h"
@@ -373,30 +373,26 @@ SearchStmtCache(const char *ecpgQuery)
373373
* OR negative error code
374374
*/
375375
staticint
376-
ecpg_freeStmtCacheEntry(intentNo)/* entry # to free*/
376+
ecpg_freeStmtCacheEntry(intlineno,intcompat,intentNo)/* entry # to free*/
377377
{
378378
stmtCacheEntry*entry;
379-
PGresult*results;
380-
chardeallocText[100];
381379
structconnection*con;
380+
structprepared_statement*this,*prev;
382381

383382
entry=&stmtCacheEntries[entNo];
384383
if (!entry->stmtID[0])/* return if the entry isn't in use */
385384
return (0);
386385

387386
con=ecpg_get_connection(entry->connection);
388-
/* free the server resources for the statement*/
389-
ecpg_log("ecpg_freeStmtCacheEntry line %d: deallocate %s, cache entry #%d\n",entry->lineno,entry->stmtID,entNo);
390-
sprintf(deallocText,"DEALLOCATE PREPARE %s",entry->stmtID);
391-
results=PQexec(con->connection,deallocText);
392387

393-
if (!ecpg_check_PQresult(results,entry->lineno,con->connection,ECPG_COMPAT_PGSQL))
388+
/* free the 'prepared_statement' list entry */
389+
this=find_prepared_statement(entry->stmtID,con,&prev);
390+
if (this&& !deallocate_one(lineno,compat,con,prev,this))
394391
return (-1);
395-
PQclear(results);
396392

397393
entry->stmtID[0]='\0';
398394

399-
/* free the memory used by the cache entry*/
395+
/* free the memory used by the cache entry*/
400396
if (entry->ecpgQuery)
401397
{
402398
ecpg_free(entry->ecpgQuery);
@@ -414,6 +410,7 @@ static int
414410
AddStmtToCache(intlineno,/* line # of statement*/
415411
char*stmtID,/* statement ID*/
416412
constchar*connection,/* connection*/
413+
intcompat,/* compatibility level */
417414
constchar*ecpgQuery)/* query*/
418415
{
419416
intix,
@@ -444,7 +441,7 @@ AddStmtToCache(int lineno,/* line # of statement*/
444441
entNo=luEntNo;/* re-use the 'least used' entry*/
445442

446443
/* 'entNo' is the entry to use - make sure its free*/
447-
if (ecpg_freeStmtCacheEntry(entNo)<0)
444+
if (ecpg_freeStmtCacheEntry(lineno,compat,entNo)<0)
448445
return (-1);
449446

450447
/* add the query to the entry*/
@@ -460,7 +457,7 @@ AddStmtToCache(int lineno,/* line # of statement*/
460457

461458
/* handle cache and preparation of statments in auto-prepare mode */
462459
bool
463-
ecpg_auto_prepare(intlineno,constchar*connection_name,constintquestionmarks,char**name,constchar*query)
460+
ecpg_auto_prepare(intlineno,constchar*connection_name,intcompat,constintquestionmarks,char**name,constchar*query)
464461
{
465462
intentNo;
466463

@@ -483,7 +480,7 @@ ecpg_auto_prepare(int lineno, const char *connection_name, const int questionmar
483480

484481
if (!ECPGprepare(lineno,connection_name,questionmarks,ecpg_strdup(*name,lineno),query))
485482
return (false);
486-
if (AddStmtToCache(lineno,*name,connection_name,query)<0)
483+
if (AddStmtToCache(lineno,*name,connection_name,compat,query)<0)
487484
return (false);
488485
}
489486

‎src/interfaces/ecpg/preproc/variable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.43 2007/12/21 14:33:20 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.44 2008/02/07 11:09:13 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -237,7 +237,7 @@ find_variable(char *name)
237237
caseECPGt_union:
238238
return (new_variable(name,ECPGmake_struct_type(p->type->u.element->u.members,p->type->u.element->type,p->type->u.element->struct_sizeof),p->brace_level));
239239
default:
240-
return (new_variable(name,ECPGmake_simple_type(p->type->u.element->type,p->type->u.element->size,p->type->u.element->u.element->lineno),p->brace_level));
240+
return (new_variable(name,ECPGmake_simple_type(p->type->u.element->type,p->type->u.element->size,p->type->u.element->lineno),p->brace_level));
241241
}
242242
}
243243
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp