mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-02 15:24:57 +01:00
fix ODBC: losing input data in case PD_IN_OUT paramater type (#1280)
* fix: losing input data in case PD_IN_OUT paramater type * - fix allso applied for wide string - added test case 'testStoredProcedureAnyString()' for reproducing
This commit is contained in:
parent
14076f75b4
commit
23d7d2c6cb
@ -185,6 +185,10 @@ void Binder::bind(std::size_t pos, const std::string& val, Direction dir, const
|
|||||||
{
|
{
|
||||||
getColumnOrParameterSize(pos, size);
|
getColumnOrParameterSize(pos, size);
|
||||||
char* pChar = (char*) std::calloc(size, sizeof(char));
|
char* pChar = (char*) std::calloc(size, sizeof(char));
|
||||||
|
|
||||||
|
if (isInOutBound(dir))
|
||||||
|
std::strcpy(pChar,val.c_str());
|
||||||
|
|
||||||
pVal = (SQLPOINTER) pChar;
|
pVal = (SQLPOINTER) pChar;
|
||||||
_outParams.insert(ParamMap::value_type(pVal, size));
|
_outParams.insert(ParamMap::value_type(pVal, size));
|
||||||
_strings.insert(StringMap::value_type(pChar, const_cast<std::string*>(&val)));
|
_strings.insert(StringMap::value_type(pChar, const_cast<std::string*>(&val)));
|
||||||
@ -240,6 +244,8 @@ void Binder::bind(std::size_t pos, const UTF16String& val, Direction dir, const
|
|||||||
getColumnOrParameterSize(pos, size);
|
getColumnOrParameterSize(pos, size);
|
||||||
CharT* pChar = (CharT*)std::calloc(size, sizeof(CharT));
|
CharT* pChar = (CharT*)std::calloc(size, sizeof(CharT));
|
||||||
pVal = (SQLPOINTER)pChar;
|
pVal = (SQLPOINTER)pChar;
|
||||||
|
if (isInOutBound(dir))
|
||||||
|
std::wcscpy(pChar,val.c_str());
|
||||||
_outParams.insert(ParamMap::value_type(pVal, size));
|
_outParams.insert(ParamMap::value_type(pVal, size));
|
||||||
_utf16Strings.insert(UTF16StringMap::value_type(pChar, const_cast<UTF16String*>(&val)));
|
_utf16Strings.insert(UTF16StringMap::value_type(pChar, const_cast<UTF16String*>(&val)));
|
||||||
}
|
}
|
||||||
|
@ -355,6 +355,20 @@ void ODBCOracleTest::testStoredProcedureAny()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ODBCOracleTest::testStoredProcedureAnyString()
|
||||||
|
{
|
||||||
|
Any sInOut = std::string("Hello");
|
||||||
|
|
||||||
|
*_pSession << "CREATE OR REPLACE "
|
||||||
|
"PROCEDURE storedProcedure(inParam IN OUT VARCHAR2) IS "
|
||||||
|
" BEGIN inParam := inParam||' world!'; "
|
||||||
|
"END storedProcedure;" , now;
|
||||||
|
|
||||||
|
*_pSession << "{call storedProcedure(?)}", io(sInOut), now;
|
||||||
|
assert("Hello world!" == AnyCast<std::string>(sInOut));
|
||||||
|
*_pSession << "DROP PROCEDURE storedProcedure;", now;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ODBCOracleTest::testStoredProcedureDynamicAny()
|
void ODBCOracleTest::testStoredProcedureDynamicAny()
|
||||||
{
|
{
|
||||||
@ -933,6 +947,7 @@ CppUnit::Test* ODBCOracleTest::suite()
|
|||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedure);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedure);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testCursorStoredProcedure);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testCursorStoredProcedure);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedureAny);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedureAny);
|
||||||
|
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedureAnyString);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedureDynamicAny);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedureDynamicAny);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredFunction);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testStoredFunction);
|
||||||
CppUnit_addTest(pSuite, ODBCOracleTest, testCursorStoredFunction);
|
CppUnit_addTest(pSuite, ODBCOracleTest, testCursorStoredFunction);
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
void testStoredFunction();
|
void testStoredFunction();
|
||||||
void testCursorStoredFunction();
|
void testCursorStoredFunction();
|
||||||
void testStoredProcedureAny();
|
void testStoredProcedureAny();
|
||||||
|
void testStoredProcedureAnyString();
|
||||||
void testStoredProcedureDynamicAny();
|
void testStoredProcedureDynamicAny();
|
||||||
void testAutoTransaction();
|
void testAutoTransaction();
|
||||||
|
|
||||||
|
@ -405,6 +405,9 @@ public:
|
|||||||
|
|
||||||
static bool isInBound(Direction dir);
|
static bool isInBound(Direction dir);
|
||||||
/// Returns true if direction is in bound;
|
/// Returns true if direction is in bound;
|
||||||
|
|
||||||
|
static bool isInOutBound(Direction dir);
|
||||||
|
/// Returns true if direction is in and out bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -422,6 +425,10 @@ inline bool AbstractBinder::isOutBound(Direction dir)
|
|||||||
return PD_OUT == dir || PD_IN_OUT == dir;
|
return PD_OUT == dir || PD_IN_OUT == dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool AbstractBinder::isInOutBound(Direction dir)
|
||||||
|
{
|
||||||
|
return PD_IN_OUT == dir;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool AbstractBinder::isInBound(Direction dir)
|
inline bool AbstractBinder::isInBound(Direction dir)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user