-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workaround for unixODBC bug returning error when getting numcol #344
Conversation
e branch 'error_numcol' of https://github.com/v-kaywon/msphpsql into error_numcol get change :wq
…nto error_numcol to get updates .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens when stmt->current_results is NULL?
@yitam , it should not do anything when it is NULL. I should put
inside the if block Thanks you for your sharp eyes :) |
source/shared/core_sqlsrv.h
Outdated
// (HY010 error should not return if stmt->execute is true) | ||
#ifndef _WIN32 | ||
sqlsrv_error_auto_ptr error; | ||
if ( stmt->current_results != NULL ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to make changes, but you can actually declare the variable error inside the IF block ;)
Or, consider checking for two conditions: if current_results != NULL && stmt->executed is true
--FILE-- | ||
<?php | ||
require_once("pdo_tools.inc"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you don't have to include "pdo_tools.inc", but since you have it, you might want to create a temporary table instead (no need to check for a table's existence then drop it later)
$stmt = $conn->prepare($sql); | ||
$stmt->execute(); | ||
if ($conn->errorCode() == 00000) | ||
echo "prepare OK\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need quotes around 00000?
source/shared/core_sqlsrv.h
Outdated
// but it should have succeeded with r=0 (SQL_SUCCESS) and no error | ||
// instead of throwing an exception, return 0 if the r=-1, stament has been executed, and has a HY010 error | ||
// (HY010 error should not return if stmt->execute is true) | ||
#ifndef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you execute a large batch of SQL statements, for example 10000 inserts? According to this page, SQLNumResultCols() might return HY010 when executing function is still executing.
echo "prepare with args OK\n"; | ||
|
||
//test direct exec | ||
$stmt = $conn->exec($sql); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test would be more accurate, if we check the actual return value of $conn->exec($sql);
too.
FIx for #336
unixODBC returns error when getting the numcol after pdo::exec on a query that returns SQL_NO_DATA
workaround by returning 0 so pdo::exec doesn't throw an exception