diff options
author | Michael Meskes <meskes@postgresql.org> | 2007-09-30 11:38:48 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2007-09-30 11:38:48 +0000 |
commit | 60e83cec5792549323f41281f2a3608f71fc8f35 (patch) | |
tree | bb1d826ec95a33710dcc13baa0126ecaaa63d66f /src/interfaces/ecpg/ecpglib/prepare.c | |
parent | ae57efed4a1a26bcbb8b1d8cd08fd0e58c69b7fb (diff) |
Applied another patch by ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>
to get memory allocation thread-safe. He also did some cleaning up.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/prepare.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/prepare.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index 6d884bfb0ae..1afa63c9339 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.20 2007/09/26 10:57:00 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.21 2007/09/30 11:38:48 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -31,8 +31,8 @@ typedef struct } stmtCacheEntry; static int nextStmtID = 1; -static int stmtCacheNBuckets = 2039; /* # buckets - a prime # */ -static int stmtCacheEntPerBucket = 8; /* # entries/bucket */ +const static int stmtCacheNBuckets = 2039; /* # buckets - a prime # */ +const static int stmtCacheEntPerBucket = 8; /* # entries/bucket */ static stmtCacheEntry stmtCacheEntries[16384] = {{0,{0},0,0,0}}; static struct prepared_statement *find_prepared_statement(const char *name, @@ -263,22 +263,24 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name) } bool -ECPGdeallocate_all(int lineno, int compat, const char *connection_name) +ECPGdeallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *con) { - struct connection *con; - - con = ECPGget_connection(connection_name); - /* deallocate all prepared statements */ while (con->prep_stmts) { - if (!deallocate_one(lineno, compat, con, NULL, con->prep_stmts)) + if (!deallocate_one(lineno, c, con, NULL, con->prep_stmts)) return false; } return true; } +bool +ECPGdeallocate_all(int lineno, int compat, const char *connection_name) +{ + return ECPGdeallocate_all_conn(lineno, compat, ECPGget_connection(connection_name)); +} + char * ECPGprepared(const char *name, struct connection *con, int lineno) { |