mirror of
https://github.com/mariadb-corporation/mariadb-connector-cpp.git
synced 2025-07-20 16:35:25 +00:00
Extended a bit the test Bytes array parameter from previous commit
to demonstatrate and check its work, and a bit of sql::bytes Corrected vendor name in cpack configuration.
This commit is contained in:
@ -5,7 +5,7 @@ IF(NOT CPACK_PACKAGE_RELEASE)
|
||||
SET(CPACK_PACKAGE_RELEASE 1)
|
||||
ENDIF()
|
||||
SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
|
||||
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation plc")
|
||||
SET(CPACK_PACKAGE_CONTACT "info@mariadb.com")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C++. C++ driver library for connecting to MariaDB and MySQL servers")
|
||||
SET(CPACK_PACKAGE_LICENSE "LGPLv2.1")
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* 2020, 2024 MariaDB Corporation plc
|
||||
* 2020, 2025 MariaDB Corporation plc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2.0, as
|
||||
@ -2218,14 +2218,31 @@ void preparedstatement::multirs_caching()
|
||||
ASSERT_EQUALS(-1, pstmt1->getUpdateCount());
|
||||
}
|
||||
|
||||
void preparedstatement::negativeBytesLength()
|
||||
void preparedstatement::bytesArrParam()
|
||||
{
|
||||
pstmt.reset(con->prepareStatement("SELECT ?"));
|
||||
char charArray[1];
|
||||
sql::bytes sqlBytes{ charArray, 1 };
|
||||
//sqlBytes have a negative length, let's see if it throws
|
||||
char charArray[3]= {'\1', '\0', '\1'};
|
||||
sql::bytes sqlBytes(charArray, 3), b2{'\1', '\0', '\2'};
|
||||
b2[2]= '\0';
|
||||
// sqlBytes has internally a negative length, i.e. it does not own the array. let's see if it throws
|
||||
pstmt->setBytes(1, &sqlBytes);
|
||||
pstmt->executeQuery();
|
||||
res.reset(pstmt->executeQuery());
|
||||
ASSERT(res->next());
|
||||
ASSERT_EQUALS(65537, res->getInt(1));
|
||||
|
||||
// b2 owns the array and internal length is positive - checking it's also alright
|
||||
pstmt->setBytes(1, &b2);
|
||||
res.reset(pstmt->executeQuery());
|
||||
ASSERT(res->next());
|
||||
ASSERT_EQUALS(65536, res->getInt(1));
|
||||
|
||||
sqlBytes[0]= '\0';
|
||||
// Just to show, that original array has been changed
|
||||
ASSERT_EQUALS('\0', charArray[0]);
|
||||
pstmt->setBytes(1, &sqlBytes);
|
||||
res.reset(pstmt->executeQuery());
|
||||
ASSERT(res->next());
|
||||
ASSERT_EQUALS(1, res->getInt(1));
|
||||
}
|
||||
|
||||
} /* namespace preparedstatement */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* 2020, 2023 MariaDB Corporation AB
|
||||
* 2020, 2025 MariaDB Corporation plc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2.0, as
|
||||
@ -79,7 +79,7 @@ public:
|
||||
TEST_CASE(concpp106_batchBulk);
|
||||
TEST_CASE(concpp116_getByte);
|
||||
TEST_CASE(multirs_caching);
|
||||
TEST_CASE(negativeBytesLength);
|
||||
TEST_CASE(bytesArrParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +173,9 @@ public:
|
||||
void multirs_caching();
|
||||
|
||||
/**
|
||||
* sql::bytes may be negative and cause problems
|
||||
* sql::bytes may have negative length(internally) and that caused problems
|
||||
*/
|
||||
void negativeBytesLength();
|
||||
void bytesArrParam();
|
||||
|
||||
/* unit_fixture methods overriding */
|
||||
void setUp();
|
||||
|
Reference in New Issue
Block a user