-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix length read from app ptr when param binding (#173)
This commit fixes the length handling of received wide-char strings as parameters: the indicator-length pointer of the API call provides the octet count, so the lenght needs to be divided by wide-char size. Besides a couple of tests for the fix, the commit adds a new test on null generation (both of non-NULL and NULL types). (cherry picked from commit 29376ec) Resolved conflict: s/WAPI_ERRNO/WCS2U8_ERRNO/ .
- Loading branch information
Showing
3 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include "connected_dbc.h" | ||
|
||
namespace test { | ||
|
||
class ConvertC2SQL_Null : public ::testing::Test, public ConnectedDBC { | ||
}; | ||
|
||
|
||
TEST_F(ConvertC2SQL_Null, CStr2Boolean_null) | ||
{ | ||
prepareStatement(); | ||
|
||
SQLCHAR val[] = "1"; | ||
SQLLEN osize = SQL_NULL_DATA; | ||
ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, | ||
ESODBC_SQL_BOOLEAN, /*size*/0, /*decdigits*/0, val, | ||
sizeof(val) - /*\0*/1, &osize); | ||
ASSERT_TRUE(SQL_SUCCEEDED(ret)); | ||
|
||
assertRequest("[{\"type\": \"BOOLEAN\", \"value\": null}]"); | ||
} | ||
|
||
TEST_F(ConvertC2SQL_Null, WStr2Null) | ||
{ | ||
prepareStatement(); | ||
|
||
SQLWCHAR val[] = L"0X"; | ||
ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_WCHAR, | ||
ESODBC_SQL_NULL, /*size*/0, /*decdigits*/0, val, 0, NULL); | ||
ASSERT_TRUE(SQL_SUCCEEDED(ret)); | ||
|
||
assertRequest("[{\"type\": \"NULL\", \"value\": null}]"); | ||
} | ||
|
||
|
||
} // test namespace | ||
|
||
/* vim: set noet fenc=utf-8 ff=dos sts=0 sw=4 ts=4 : */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters