This fixes an infinite loop reported by Nelson Andre.
* has not transitioned to "connected" yet.
*/
- result = PGAPI_AllocStmt(self, &hstmt);
+ result = PGAPI_AllocStmt(self, &hstmt, 0);
if (!SQL_SUCCEEDED(result))
return FALSE;
stmt = (StatementClass *) hstmt;
* has not transitioned to "connected" yet.
*/
- result = PGAPI_AllocStmt(self, &hstmt);
+ result = PGAPI_AllocStmt(self, &hstmt, 0);
if (!SQL_SUCCEEDED(result))
return FALSE;
stmt = (StatementClass *) hstmt;
* This function must use the local odbc API functions since the odbc state
* has not transitioned to "connected" yet.
*/
- result = PGAPI_AllocStmt(self, &hstmt);
+ result = PGAPI_AllocStmt(self, &hstmt, 0);
if (!SQL_SUCCEEDED(result))
return;
stmt = (StatementClass *) hstmt;
conn = SC_get_conn(stmt);
ci = &(conn->connInfo);
- result = PGAPI_AllocStmt(conn, &htbl_stmt);
+ result = PGAPI_AllocStmt(conn, &htbl_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_Tables result.", func);
strcat(columns_query, " order by c.relname, attnum");
}
- result = PGAPI_AllocStmt(conn, &hcol_stmt);
+ result = PGAPI_AllocStmt(conn, &hcol_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_Columns result.", func);
my_strcat1(columns_query, " and u.usename %s'%.*s'", eq_string, escSchemaName, SQL_NTS);
- result = PGAPI_AllocStmt(conn, &hcol_stmt);
+ result = PGAPI_AllocStmt(conn, &hcol_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for SQLSpecialColumns result.", func);
* we need to get a list of the field names first, so we can return
* them later.
*/
- result = PGAPI_AllocStmt(conn, &hcol_stmt);
+ result = PGAPI_AllocStmt(conn, &hcol_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in PGAPI_Statistics for columns.", func);
}
/* get a list of indexes on this table */
- result = PGAPI_AllocStmt(conn, &hindx_stmt);
+ result = PGAPI_AllocStmt(conn, &hindx_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "PGAPI_AllocStmt failed in SQLStatistics for indices.", func);
QR_set_field_info_v(res, PKS_PK_NAME, "PK_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING);
conn = SC_get_conn(stmt);
- result = PGAPI_AllocStmt(conn, &htbl_stmt);
+ result = PGAPI_AllocStmt(conn, &htbl_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for Primary Key result.", func);
SC_set_current_col(stmt, -1);
conn = SC_get_conn(stmt);
- result = PGAPI_AllocStmt(conn, &htbl_stmt);
+ result = PGAPI_AllocStmt(conn, &htbl_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys result.", func);
goto cleanup;
}
- keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt);
+ keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt, 0);
if (!SQL_SUCCEEDED(keyresult))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys (pkeys) result.", func);
/*
* get pk_name here
*/
- keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt);
+ keyresult = PGAPI_AllocStmt(conn, &hpkey_stmt, 0);
if (!SQL_SUCCEEDED(keyresult))
{
SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Couldn't allocate statement for PGAPI_ForeignKeys (pkeys) result.", func);
HSTMT hstmt;
RETCODE result;
- result = PGAPI_AllocStmt(self, &hstmt);
+ result = PGAPI_AllocStmt(self, &hstmt, 0);
if (!SQL_SUCCEEDED(result))
return encstr;
mylog("[SQLAllocStmt]");
ENTER_CONN_CS(conn);
CC_clear_error(conn);
- ret = PGAPI_AllocStmt(ConnectionHandle, StatementHandle);
+ ret = PGAPI_AllocStmt(ConnectionHandle, StatementHandle, PODBC_EXTERNAL_STATEMENT | PODBC_INHERIT_CONNECT_OPTIONS);
LEAVE_CONN_CS(conn);
return ret;
}
break;
case SQL_HANDLE_STMT:
ENTER_CONN_CS((ConnectionClass *) InputHandle);
- ret = PGAPI_AllocStmt(InputHandle, OutputHandle);
+ ret = PGAPI_AllocStmt(InputHandle, OutputHandle, PODBC_EXTERNAL_STATEMENT | PODBC_INHERIT_CONNECT_OPTIONS);
LEAVE_CONN_CS((ConnectionClass *) InputHandle);
break;
case SQL_HANDLE_DESC:
if (NULL == conn)
conn = SC_get_conn(stmt);
- result = PGAPI_AllocStmt(conn, &hcol_stmt);
+ result = PGAPI_AllocStmt(conn, &hcol_stmt, 0);
if (!SQL_SUCCEEDED(result))
{
if (stmt)
char keycolnam[MAX_INFO_STRING];
SQLLEN keycollen;
- ret = PGAPI_AllocStmt(conn, &pstmt);
+ ret = PGAPI_AllocStmt(conn, &pstmt, 0);
if (!SQL_SUCCEEDED(ret))
return ret;
oneti = ti[0];
#define PODBC_NOT_SEARCH_PATTERN 1L
#define PODBC_SEARCH_PUBLIC_SCHEMA (1L << 1)
#define PODBC_SEARCH_BY_IDS (1L << 2)
+/* Internal flags for PGAPI_AllocStmt functions */
+#define PODBC_EXTERNAL_STATEMENT 1L /* visible to the driver manager */
+#define PODBC_INHERIT_CONNECT_OPTIONS (1L << 1)
/* Internal flags for PGAPI_Exec... functions */
#define PODBC_WITH_HOLD 1L
#define PODBC_PER_STATEMENT_ROLLBACK (1L << 1)
HDBC FAR * ConnectionHandle);
RETCODE SQL_API PGAPI_AllocEnv(HENV FAR * EnvironmentHandle);
RETCODE SQL_API PGAPI_AllocStmt(HDBC ConnectionHandle,
- HSTMT *StatementHandle);
+ HSTMT *StatementHandle, UDWORD flag);
RETCODE SQL_API PGAPI_BindCol(HSTMT StatementHandle,
SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
PTR TargetValue, SQLLEN BufferLength,
if (PG_VERSION_GE(conn, 8.2))
strcat(updstr, " returning ctid");
mylog("updstr=%s\n", updstr);
- if (PGAPI_AllocStmt(conn, &hstmt) != SQL_SUCCESS)
+ if (PGAPI_AllocStmt(conn, &hstmt, 0) != SQL_SUCCESS)
{
SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "internal AllocStmt error", func);
return SQL_ERROR;
sprintf(addstr, "insert into \"%s\".\"%s\" (", SAFE_NAME(s.stmt->ti[0]->schema_name), SAFE_NAME(s.stmt->ti[0]->table_name));
else
sprintf(addstr, "insert into \"%s\" (", SAFE_NAME(s.stmt->ti[0]->table_name));
- if (PGAPI_AllocStmt(conn, &hstmt) != SQL_SUCCESS)
+ if (PGAPI_AllocStmt(conn, &hstmt, 0) != SQL_SUCCESS)
{
SC_set_error(s.stmt, STMT_NO_MEMORY_ERROR, "internal AllocStmt error", func);
return SQL_ERROR;
RETCODE SQL_API
PGAPI_AllocStmt(HDBC hdbc,
- HSTMT FAR * phstmt)
+ HSTMT FAR * phstmt, UDWORD flag)
{
CSTR func = "PGAPI_AllocStmt";
ConnectionClass *conn = (ConnectionClass *) hdbc;
*phstmt = (HSTMT) stmt;
+ stmt->iflag = flag;
/* Copy default statement options based from Connection options */
- stmt->options = stmt->options_orig = conn->stmtOptions;
- stmt->ardi.ardopts = conn->ardOptions;
+ if (0 != (PODBC_INHERIT_CONNECT_OPTIONS & flag))
+ {
+ stmt->options = stmt->options_orig = conn->stmtOptions;
+ stmt->ardi.ardopts = conn->ardOptions;
+ }
+ else
+ {
+ stmt->options_orig = stmt->options;
+ InitializeARDFields(&stmt->ardi.ardopts);
+ }
ardopts = SC_get_ARDF(stmt);
bookmark = ARD_AllocBookmark(ardopts);
self->parse_method = 0;
if (!conn) return;
+ if (0 == (PODBC_EXTERNAL_STATEMENT & self->iflag)) return;
if (self->catalog_result) return;
if (conn->connInfo.drivers.parse)
SC_set_parse_forced(self);
rv->prepared = NOT_YET_PREPARED;
rv->status = STMT_ALLOCATED;
rv->internal = FALSE;
+ rv->iflag = 0;
rv->plan_name = NULL;
rv->transition_status = STMT_TRANSITION_UNALLOCATED;
rv->multi_statement = -1; /* unknown */
Int2 data_at_exec; /* Number of params needing SQLPutData */
Int2 current_exec_param; /* The current parameter for
* SQLPutData */
+ UDWORD iflag; /* PGAPI_AllocStmt parameter */
PutDataInfo pdata_info;
po_ind_t parse_status;
po_ind_t proc_return;
#define POSTGRESDRIVERVERSION "09.00.0201"
#define POSTGRES_RESOURCE_VERSION "09.00.0201\0"
#define PG_DRVFILE_VERSION 9,0,02,01
-#define PG_BUILD_VERSION "201011060001"
+#define PG_BUILD_VERSION "201011080001"
#endif