Skip to content

Commit

Permalink
Merge 74d961a into 3cd248f
Browse files Browse the repository at this point in the history
  • Loading branch information
absci authored May 11, 2023
2 parents 3cd248f + 74d961a commit 057ac31
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/shared/core_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,9 @@ void sqlsrv_param::bind_param(_Inout_ sqlsrv_stmt* stmt)
}

core::SQLBindParameter(stmt, param_pos + 1, direction, c_data_type, sql_data_type, column_size, decimal_digits, buffer, buffer_length, &strlen_or_indptr);
if (!stmt->conn->ce_option.enabled && !stmt->format_decimals) {
sql_data_type = SQL_UNKNOWN_TYPE;
}
}

void sqlsrv_param::init_data_from_zval(_Inout_ sqlsrv_stmt* stmt)
Expand Down
34 changes: 34 additions & 0 deletions test/functional/sqlsrv/sqlsrv_github_1448.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
Test for Github Issue 1448
--DESCRIPTION--
Prepare and execute with int, then execute with string caused "Invalid character value for cast specification" error.
Repro script provided by thsmrtone1
--FILE--
<?php
sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );

require_once( 'MsCommon.inc' );
$conn = Connect();
if( !$conn ) {
var_dump( sqlsrv_errors() );
die( "sqlsrv_connect failed." );
}

sqlsrv_query($conn, "CREATE TABLE test1448 (testCol nvarchar(50) NULL)");

$v0 = 1000;
$stmt = sqlsrv_prepare($conn, 'INSERT INTO [test1448] (testCol) VALUES (?);', [&$v0]);
sqlsrv_execute($stmt);

$v0 = 'abcd';
sqlsrv_execute($stmt);

$error = sqlsrv_errors(SQLSRV_ERR_ERRORS);
var_dump($error);

dropTable($conn, "test1448");
sqlsrv_close($conn);
?>
--EXPECT--
NULL

0 comments on commit 057ac31

Please sign in to comment.