[BUG] Statement binding fail on second loop iteration
See original GitHub issueHi, first of all, thank you for this awesome odbc lib ! Here is a bug I’ve encountered :
odbcPackage Version: 2.3.3- ODBC Driver: Actian Vector Ingress 3.50
- Database Name: Actian Vector
- Database Version: 5.1
- Database OS: Linux
- Node.js Version: v12.13.1
- Node.js OS: Ubuntu 18.04.4 LTS
Describe the bug An error is raised when binding a statement for the second time. This second bind data is as valid as the first one.
Expected behavior I should be able to bind a statement several time.
Code
async runForEach(queryTemplate, values) {
console.log('\nMY CODE runForEach');
const statement = await this.db.createStatement();
await statement.prepare(queryTemplate);
for(const val of values) {
console.log('\nMY CODE loop');
await statement.bind(val);
console.log('\nMY CODE binded');
await statement.execute();
console.log('\nMY CODE executed');
}
await statement.close();
}
MY CODE runForEach
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20] ODBCConnection::CreateStatement()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20] ODBCConnection::CreateStatementAsyncWorker:Execute()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::CreateStatementAsyncWorker::OnOK()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::Prepare()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute(): Running SQLPrepare(StatementHandle = 0x7fc1c81ad3e0, StatementText = INSERT INTO test_operator VALUES (?, ?, ?, ?, ?);, TextLength = -3)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute(): SQLPrepare succeeded: SQLRETURN = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute(): Running SQLNumParams(StatementHandle = 0x7fc1c81ad3e0, ParameterCountPtr = 0x3b87db8
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute(): SQLNumParams succeeded: SQLRETURN = 0, ParameterCount = 5
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::OnOk()
MY CODE loop
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::Bind()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::BindAsyncWorker::Execute()
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): Calling SQLBindParameter(StatementHandle = 0x7fc1c81ad3e0, ParameterNumber = 0, InputOutputType = 1, ValueType = -25, ParameterType = 4, ColumnSize = 4, DecimalDigits = 0, ParameterValuePtr = 0x3bf8340, BufferLength = 0, StrLen_or_IndPtr = 0x7fc1bc052568)
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): SQLBindParameter passed with SQLRETURN = 0, StrLen_or_IndPtr = 0[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): Calling SQLBindParameter(StatementHandle = 0x7fc1c81ad3e0, ParameterNumber = 2, InputOutputType = 1, ValueType = -8, ParameterType = 12, ColumnSize = 255, DecimalDigits = 0, ParameterValuePtr = 0x7fc1bc01b670, BufferLength = 12, StrLen_or_IndPtr = 0x7fc1bc053818)
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): SQLBindParameter passed with SQLRETURN = 0, StrLen_or_IndPtr = -3[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): Calling SQLBindParameter(StatementHandle = 0x7fc1c81ad3e0, ParameterNumber = 4, InputOutputType = 1, ValueType = -8, ParameterType = 12, ColumnSize = 255, DecimalDigits = 0, ParameterValuePtr = 0x7fc1bc052050, BufferLength = 14, StrLen_or_IndPtr = 0x7fc1bc053928)
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): SQLBindParameter passed with SQLRETURN = 0, StrLen_or_IndPtr = -3[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): Calling SQLBindParameter(StatementHandle = 0x7fc1c81ad3e0, ParameterNumber = 6, InputOutputType = 1, ValueType = -8, ParameterType = 12, ColumnSize = 255, DecimalDigits = 0, ParameterValuePtr = 0x3a80750, BufferLength = 82, StrLen_or_IndPtr = 0x7fc1bc053a38)
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): SQLBindParameter passed with SQLRETURN = 0, StrLen_or_IndPtr = -3[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): Calling SQLBindParameter(StatementHandle = 0x7fc1c81ad3e0, ParameterNumber = 8, InputOutputType = 1, ValueType = -8, ParameterType = 12, ColumnSize = 255, DecimalDigits = 0, ParameterValuePtr = 0x7fc1bc01b690, BufferLength = 6, StrLen_or_IndPtr = 0x7fc1bc053b48)
[TODO][SQLHSTMT: 0x7fc1c81ad3e0] ODBC::BindParameters(): SQLBindParameter passed with SQLRETURN = 0, StrLen_or_IndPtr = -3[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::BindAsyncWorker::OnOk()
MY CODE binded
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::Execute()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::ExecuteAsyncWorker::Execute()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::ExecuteAsyncWorker::Execute(): Running SQLExecute(StatementHandle = 0x7fc1c81ad3e0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::ExecuteAsyncWorker::Execute(): SQLExecute succeeded
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::RetrieveResultSet()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::RetrieveResultSet(): Running SQLRowCount(StatementHandle = 0x7fc1c81ad3e0, RowCount = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::RetrieveResultSet(): SQLRowCount passed: SQLRETURN = 0, RowCount = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::BindColumns()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::BindColumns(): Running SQLNumResultCols(StatementHandle = 0x7fc1c81ad3e0, ColumnCount = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCConnection::BindColumns(): SQLNumResultCols passed: ColumnCount = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::ExecuteAsyncWorker::OnOk()
MY CODE executed
MY CODE loop
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::Bind()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::BindAsyncWorker::Execute()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1c81ad3e0] ODBCStatement::PrepareAsyncWorker::Execute(): DescribeParameters returned code -1
ODBC::GetSQLError : handleType=3, handle=0x7fc1c81ad3e0
ODBC::GetSQLError : called SQLGetDiagField; ret=0, statusRecCount=1
ODBC::GetSQLError : calling SQLGetDiagRec; i=0, statusRecCount=1
ODBC::GetSQLError : errorMessage=[unixODBC][Driver Manager]Function sequence error, errorSQLState=HY010
[Error: [odbc] Error retrieving information about the parameters in the statement] {
odbcErrors: [
{
state: 'HY010',
code: 0,
message: '[unixODBC][Driver Manager]Function sequence error'
}
]
}
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: (nil)] ODBCConnection::TablesAsyncWorker::Execute(): Calling SQLAllocHandle(HandleType = 3, InputHandle = 0x7fc1c8000b20, OutputHandlePtr = 0x3b86620)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20] ODBCConnection::TablesProcedureAsyncWorker::Execute(): SQLAllocHandle succeeded: SQLRETURN = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::TablesAsyncWorker::Execute(): Calling SQLTables(StatementHandle = 0x7fc1bc052580, CatalogName = (null), NameLength1 = -3, SchemaName = (null), NameLength2 = -3, TableName = (null), NameLength3 = -3, TableType = (null), NameLength4 = -3)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::RetrieveResultSet()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::RetrieveResultSet(): Running SQLRowCount(StatementHandle = 0x7fc1bc052580, RowCount = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::RetrieveResultSet(): SQLRowCount passed: SQLRETURN = 0, RowCount = -1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLNumResultCols(StatementHandle = 0x7fc1bc052580, ColumnCount = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLNumResultCols passed: ColumnCount = 5
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLDescribeCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 1, ColumnName = , BufferLength = 256, NameLength = 0, DataType = 0, ColumnSize = 0, DecimalDigits = 0, Nullable = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = TABLE_CAT, NameLength = 9, DataType = 12, ColumnSize = 1, DecimalDigits = 0, Nullable = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLBindCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 1, TargetType = 1, TargetValuePtr = 0x7fc1bc003110, BufferLength = 5, StrLen_or_Ind = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLBindCol succeeded: StrLeng_or_IndPtr = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLDescribeCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 2, ColumnName = , BufferLength = 256, NameLength = 0, DataType = 0, ColumnSize = 0, DecimalDigits = 0, Nullable = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = TABLE_SCHEM, NameLength = 11, DataType = 12, ColumnSize = 32, DecimalDigits = 0, Nullable = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLBindCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 2, TargetType = 1, TargetValuePtr = 0x7fc1bc01f040, BufferLength = 129, StrLen_or_Ind = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLBindCol succeeded: StrLeng_or_IndPtr = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLDescribeCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 3, ColumnName = , BufferLength = 256, NameLength = 0, DataType = 0, ColumnSize = 0, DecimalDigits = 0, Nullable = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = TABLE_NAME, NameLength = 10, DataType = 12, ColumnSize = 256, DecimalDigits = 0, Nullable = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLBindCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 3, TargetType = 1, TargetValuePtr = 0x7fc1bc056240, BufferLength = 1025, StrLen_or_Ind = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLBindCol succeeded: StrLeng_or_IndPtr = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLDescribeCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 4, ColumnName = , BufferLength = 256, NameLength = 0, DataType = 0, ColumnSize = 0, DecimalDigits = 0, Nullable = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = TABLE_TYPE, NameLength = 10, DataType = 12, ColumnSize = 12, DecimalDigits = 0, Nullable = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLBindCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 4, TargetType = 1, TargetValuePtr = 0x7fc1bc053c30, BufferLength = 49, StrLen_or_Ind = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLBindCol succeeded: StrLeng_or_IndPtr = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLDescribeCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 5, ColumnName = , BufferLength = 256, NameLength = 0, DataType = 0, ColumnSize = 0, DecimalDigits = 0, Nullable = 0)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLDescribeCol passed: ColumnName = REMARKS, NameLength = 7, DataType = 12, ColumnSize = 1600, DecimalDigits = 0, Nullable = 1
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): Running SQLBindCol(StatementHandle = 0x7fc1bc052580, ColumnNumber = 5, TargetType = 1, TargetValuePtr = 0x7fc1bc022fc0, BufferLength = 6401, StrLen_or_Ind = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::BindColumns(): SQLBindCol succeeded: StrLeng_or_IndPtr = 0
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::FetchAll()
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::FetchAll(): Running SQLFetch(StatementHandle = 0x7fc1bc052580) (Running multiple times)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::FetchAll(): SQLFetch succeeded: Stored 140 rows of data, each with 5 columns
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::FetchAll(): Running SQLCloseCursor(StatementHandle = 0x7fc1bc052580) (Running multiple times)
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20][SQLHSTMT: 0x7fc1bc052580] ODBCConnection::FetchAll(): SQLCloseCursor succeeded
[SQLHENV: 0x3c1a540][SQLHDBC: 0x7fc1c8000b20] ODBCConnection::TablesProcedureAsyncWorker::OnOk()
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Javascript for loop until error - Stack Overflow
If I push the iterations too high, it will throw a "TypeError", which indicates that the limit has been reached. This for loop...
Read more >redefining for loop variable semantics #56010 - GitHub
This happens because the item variable is per-loop, not per-iteration: &item is the same on every iteration, and item is overwritten on each ......
Read more >3.1 About error conditions - LispWorks
Reason: The Loop Facility parses the form that you give it token by token. Each token is one of the items in the...
Read more >21 Iteration | R for Data Science - Hadley Wickham
In this chapter you'll learn about two important iteration paradigms: imperative programming and functional programming. On the imperative side you have ...
Read more >4. Conditionals and loops — Beginning Python Programming ...
The loop variable is created when the for statement runs, so you do not need to create the variable before then. Each iteration...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Maybe check which version of
unixODBCis installed on your system? It looks like v.2.3.5 had a number of bug fixes, includingSQLDescribeParam extraneous checks for state. Its possible your driver manager is an earlier version, and has some goofy state check that throws an error when it shouldn’t.You’re spot on ! It’s working inside my docker container. So the only “fix” needed may be a quick warning in the readme and a line to ask for the unixODBC version in the bug template 😋 Thank you very much again for your help with this ! Have a nice week.