From c07342d22d82ea6293d27057840babfc2ff6d750 Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Mon, 31 Oct 2011 14:20:20 +0000 Subject: [PATCH] Fix the bug that PostgreSQL's function calls in queries cause a crash on SQL Server linked servers. --- execute.c | 12 +----------- parse.c | 12 +++++++----- qresult.c | 8 ++++++++ version.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/execute.c b/execute.c index 5a3396e..c0ae5e8 100644 --- a/execute.c +++ b/execute.c @@ -440,17 +440,6 @@ RETCODE Exec_with_parameters_resolved(StatementClass *stmt, BOOL *exec_end) /* Prepare the statement if possible at backend side */ if (!stmt->inaccurate_result) { - /** - switch (decideHowToPrepare(stmt, FALSE)) - { - case USING_PREPARE_COMMAND: - case NAMED_PARSE_REQUEST: -#ifndef BYPASS_ONESHOT_PLAN_EXECUTION - case PARSE_TO_EXEC_ONCE: -#endif - prepare_before_exec = TRUE; - } - **/ if (HowToPrepareBeforeExec(stmt, FALSE) >= allowParse) prepare_before_exec = TRUE; } @@ -1070,6 +1059,7 @@ mylog("prepareParameters was %s called, prepare state:%d\n", shouldParse == nCal if (isSqlServr() && !stmt->internal && 0 != stmt->prepare && + PG_VERSION_LT(conn, 8.4) && SC_can_parse_statement(stmt)) parse_sqlsvr(stmt); } diff --git a/parse.c b/parse.c index 71e4bbb..47b9487 100644 --- a/parse.c +++ b/parse.c @@ -1615,13 +1615,15 @@ mylog("blevel=%d btoken=%s in_dot=%d in_field=%d tbname=%s\n", blevel, btoken, i in_dot = FALSE; in_func = TRUE; if (NULL != wfi) + { wfi->func = TRUE; - /* - * name will have the function name -- maybe useful some - * day - */ - mylog("**** got function = '%s'\n", PRINT_NAME(wfi->column_name)); + /* + * name will have the function name -- maybe useful some + * day + */ + mylog("**** got function = '%s'\n", PRINT_NAME(wfi->column_name)); + } continue; } diff --git a/qresult.c b/qresult.c index 74ad30a..82257f3 100644 --- a/qresult.c +++ b/qresult.c @@ -93,7 +93,15 @@ QR_set_cursor(QResultClass *self, const char *name) } else { + QResultClass *res; + self->cursor_name = NULL; + for (res = self->next; NULL != res; res = res->next) + { + if (NULL != res->cursor_name) + free(res->cursor_name); + res->cursor_name = NULL; + } QR_set_no_cursor(self); } } diff --git a/version.h b/version.h index c7164d5..d8b358c 100644 --- a/version.h +++ b/version.h @@ -12,6 +12,6 @@ #define POSTGRESDRIVERVERSION "09.00.0311" #define POSTGRES_RESOURCE_VERSION "09.00.0311\0" #define PG_DRVFILE_VERSION 9,0,03,11 -#define PG_BUILD_VERSION "201110150001" +#define PG_BUILD_VERSION "201110310001" #endif -- 2.39.5