pgpool2.git / summary / log / commit / refs

commit    a9a9fcb1ff492aeaea4a5cc191cd402b78d6c645
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Mon Feb 01 09:05:21 2010 +0000

    Fix timestamp rewritting.
    Fix number of parameters of Prepare.
    Fix prepared statement list to be reset when connection_cache = false.
    Patch contributed by Akio Ishida.


child.c | 2 +- pool.h | 1 + pool_process_query.c | 12 ++++++++++++ pool_timestamp.c | 2 +- test/timestamp/expected/insert.out | 1 + test/timestamp/input/insert.sql | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/child.c b/child.c index 78023d8a0..046501b33 100644 --- a/child.c +++ b/child.c @@ -419,7 +419,7 @@ void do_child(int unix_fd, int inet_fd) !strcmp(sp->database, "postgres") || !strcmp(sp->database, "regression")) { - reset_variables(); + reset_connection(); pool_close(frontend); pool_send_frontend_exits(backend); pool_discard_cp(sp->user, sp->database, sp->major); diff --git a/pool.h b/pool.h index 57bddd321..9a01674d3 100644 --- a/pool.h +++ b/pool.h @@ -691,6 +691,7 @@ extern void check_stop_request(void); /* pool_process_query.c */ extern void reset_variables(void); +extern void reset_connection(void); extern void per_node_statement_log(POOL_CONNECTION_POOL *backend, int node_id, char *query); extern POOL_STATUS pool_extract_error_message(POOL_CONNECTION *backend, int major, bool unread, char **message); extern POOL_STATUS do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backend, diff --git a/pool_process_query.c b/pool_process_query.c index 33c731f38..b26dbb95a 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -1865,6 +1865,18 @@ void reset_variables(void) receive_extended_begin = 0; } + +/* + * if connection_cache == 0, we don't need reset_query. + * but we need reset prepared list. + */ +void reset_connection(void) +{ + reset_variables(); + reset_prepared_list(&prepared_list); +} + + /* * Reset backend status. return values are: * 0: no query was issued 1: a query was issued 2: no more queries remain -1: error diff --git a/pool_timestamp.c b/pool_timestamp.c index 5557efa09..f736ff391 100644 --- a/pool_timestamp.c +++ b/pool_timestamp.c @@ -636,7 +636,7 @@ rewrite_timestamp(POOL_CONNECTION_POOL *backend, Node *node, int i; PrepareStmt *p_stmt = (PrepareStmt *) node; - for (i = ctx.num_params; i <= portal->num_tsparams; i++) + for (i = 0; i < portal->num_tsparams; i++) p_stmt->argtypes = lappend(p_stmt->argtypes, SystemTypeName("timestamptz")); } diff --git a/test/timestamp/expected/insert.out b/test/timestamp/expected/insert.out index a14368931..89e15bc7e 100644 --- a/test/timestamp/expected/insert.out +++ b/test/timestamp/expected/insert.out @@ -12,4 +12,5 @@ INSERT INTO "rel1"("c2", "c1", "c4") VALUES ('2000-1-1',1,'2009-01-01 23:59:59.1 INSERT INTO "rel1"("c2", "c1", "c4") VALUES ('2009-01-01 23:59:59.123456+09',2,'2009-01-01 23:59:59.123456+09') INSERT INTO "rel1"("c2", "c1", "c4") VALUES ('2009-01-01 23:59:59.123456+09',3,'2009-01-01 23:59:59.123456+09'), ('2009-01-01 23:59:59.123456+09',4,'2009-01-01 23:59:59.123456+09'), ('2009-1-1',5,'2009-01-01 23:59:59.123456+09') INSERT INTO rel1(c1, c2, c4) VALUES(1, '2009-1-1', '2009-2-2') +PREPARE "q" (timestamptz,timestamptz) AS INSERT INTO "rel1"("c3", "c2", "c4") VALUES (1,$1,$2) PREPARE "q" (int4,timestamptz,timestamptz) AS INSERT INTO "rel1"("c3", "c2", "c4") VALUES ($1,$2,$3) diff --git a/test/timestamp/input/insert.sql b/test/timestamp/input/insert.sql index 5c7e09418..5b7377a1d 100644 --- a/test/timestamp/input/insert.sql +++ b/test/timestamp/input/insert.sql @@ -12,4 +12,5 @@ INSERT INTO rel1(c2, c1) VALUES('2000-1-1', 1) INSERT INTO rel1(c2, c1) VALUES(DEFAULT, 2) INSERT INTO rel1(c2, c1) VALUES(DEFAULT, 3), (DEFAULT, 4), ('2009-1-1', 5) INSERT INTO rel1(c1, c2, c4) VALUES(1, '2009-1-1', '2009-2-2') +PREPARE q AS INSERT INTO rel1(c3) VALUES(1) PREPARE q(int) AS INSERT INTO rel1(c3) VALUES($1) [parent: 79f67a4b9db9]