From 2467385583b587e7a808d8e7142db2bd43dd2fb3 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Mon, 5 Dec 2005 16:44:02 +0000 Subject: [PATCH] ODBC driver fail (raise exception) with these steps (with Server Side Prepare): 1) SQLPrepare (SELECT relname FROM pg_class WHERE relname != ?) 2) SQLExecute [Ludek Finstrle] --- convert.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/convert.c b/convert.c index 5537d97..84baa56 100644 --- a/convert.c +++ b/convert.c @@ -1860,14 +1860,24 @@ Prepare_and_convert(StatementClass *stmt, QueryParse *qp, QueryBuild *qb) } if (marker_count > 0) { - CVT_APPEND_CHAR(qb, '('); - for (i = 0; i < marker_count; i++) + if (ipdopts && (ipdopts->allocated == marker_count)) { - if (i > 0) - CVT_APPEND_STR(qb, ", "); - CVT_APPEND_STR(qb, pgtype_to_name(stmt, ipdopts->parameters[i].PGType)); + CVT_APPEND_CHAR(qb, '('); + for (i = 0; i < marker_count; i++) + { + if (i > 0) + CVT_APPEND_STR(qb, ", "); + CVT_APPEND_STR(qb, pgtype_to_name(stmt, ipdopts->parameters[i].PGType)); + } + CVT_APPEND_CHAR(qb, ')'); + } + else + { + SC_set_error(stmt, STMT_COUNT_FIELD_INCORRECT, "The # of binded parameters < the # of parameter markers"); + SC_set_sqlstate(stmt, "07002"); + QB_Destructor(qb); + return SQL_ERROR; } - CVT_APPEND_CHAR(qb, ')'); } CVT_APPEND_STR(qb, " as "); for (qp->opos = 0; qp->opos < qp->stmt_len; qp->opos++) -- 2.39.5