Skip to content

Commit

Permalink
Moved C/C subproject to v3.3.4
Browse files Browse the repository at this point in the history
Also, fixed testcase for the 10.11 server
Removed 10.7 from travis config
  • Loading branch information
lawrinn committed Mar 20, 2023
1 parent c7b3644 commit 2168db0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -93,8 +93,8 @@ jobs:
name: "CS 10.4"
- env: srv=mariadb v=10.5 local=1
name: "CS 10.5"
- env: srv=mariadb v=10.7 local=1
name: "CS 10.7"
- env: srv=mariadb v=10.10 local=1
name: "CS 10.10"
- env: srv=mariadb v=10.8 local=1
name: "CS 10.8"
- env: srv=mariadb v=10.9 local=1
Expand Down
2 changes: 1 addition & 1 deletion libmariadb
16 changes: 10 additions & 6 deletions ma_string.c
Expand Up @@ -227,9 +227,13 @@ my_bool MADB_DynStrGetWhere(MADB_Stmt *Stmt, MADB_DynString *DynString, char *Ta
{
MYSQL_FIELD* field = mysql_fetch_field_direct(FetchMetadata(Stmt), i);
if (field->flags & PRI_KEY_FLAG)
PrimaryCount++;
{
++PrimaryCount;
}
if (field->flags & UNIQUE_KEY_FLAG)
UniqueCount++;
{
++UniqueCount;
}
}

TotalTableFieldCount = MADB_KeyTypeCount(Stmt->Connection, TableName, &TotalPrimaryCount, &TotalUniqueCount);
Expand All @@ -242,25 +246,25 @@ my_bool MADB_DynStrGetWhere(MADB_Stmt *Stmt, MADB_DynString *DynString, char *Ta
/* We need to use all columns, otherwise it will be difficult to map fields for Positioned Update */
if (PrimaryCount != TotalPrimaryCount)
{
PrimaryCount = 0;
PrimaryCount= 0;
}
if (UniqueCount != TotalUniqueCount)
{
UniqueCount = 0;
UniqueCount= 0;
}

/* if no primary or unique key is in the cursor, the cursor must contain all
columns from table in TableName */
/* We use unique index if we do not have primary. TODO: If there are more than one unique index - we are in trouble */
if (PrimaryCount != 0)
{
Flag = PRI_KEY_FLAG;
Flag= PRI_KEY_FLAG;
/* Changing meaning of TotalUniqueCount from field count in unique index to field count in *best* unique index(that can be primary as well) */
TotalUniqueCount= PrimaryCount;
}
else if (UniqueCount != 0)
{
Flag = UNIQUE_KEY_FLAG;
Flag= UNIQUE_KEY_FLAG;
/* TotalUniqueCount is equal UniqueCount */
}
else if (TotalTableFieldCount != MADB_STMT_COLUMN_COUNT(Stmt))
Expand Down
35 changes: 26 additions & 9 deletions test/bulk.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
2013, 2022 MariaDB Corporation AB
2013, 2023 MariaDB Corporation AB
The MySQL Connector/ODBC is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
Expand Down Expand Up @@ -437,13 +437,21 @@ ODBC_TEST(t_odbc90)
is_num(id[0], 1);
is_num(nval[0], 100);
IS_STR(sval[0], "Record 1", ind3[0] + 1);
is_num(ind4[0], 19);
/* Here and below in few places - with 10.11 we get NULL here.
Not sure if make sense check server version and expect exactly either NULL or value length */
if (ind4[0] != SQL_NULL_DATA)
{
is_num(ind4[0], 19);
}

CHECK_STMT_RC(Stmt, SQLFetchScroll(Stmt, SQL_FETCH_NEXT, 0));
is_num(id[0], 7);
is_num(nval[0], 500);
IS_STR(sval[0], "Record 21", ind3[1] + 1);
is_num(ind4[0], 19);
if (ind4[0] != SQL_NULL_DATA)
{
is_num(ind4[0], 19);
}

FAIL_IF(SQLFetchScroll(Stmt, SQL_FETCH_NEXT, 0)!=SQL_NO_DATA_FOUND, "SQL_NO_DATA_FOUND expected");

Expand Down Expand Up @@ -506,13 +514,18 @@ ODBC_TEST(t_odbc90)
is_num(id[0], 1);
is_num(nval[0], 100);
IS_STR(sval[0], "Record 1", ind3[0] + 1);
is_num(ind4[0], 19);

if (ind4[0] != SQL_NULL_DATA)
{
is_num(ind4[0], 19);
}
CHECK_STMT_RC(Stmt1, SQLFetch(Stmt1));
is_num(id[0], 7);
is_num(nval[0], 500);
IS_STR(sval[0], "Record 21", ind3[1] + 1);
is_num(ind4[0], 19);
if (ind4[0] != SQL_NULL_DATA)
{
is_num(ind4[0], 19);
}

FAIL_IF(SQLFetch(Stmt1)!=SQL_NO_DATA_FOUND, "SQL_NO_DATA_FOUND expected");

Expand Down Expand Up @@ -626,17 +639,21 @@ ODBC_TEST(t_odbc149)
memset(&Val[1], 0, sizeof(SQL_TIMESTAMP_STRUCT));
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));

is_num(tsLen[0], sizeof(SQL_TIMESTAMP_STRUCT));
if (row != 1)
{
is_num(tsLen[0], sizeof(SQL_TIMESTAMP_STRUCT));
is_num(Val[1].year, Val[row].year);
is_num(Val[1].month, Val[row].month);
is_num(Val[1].day, Val[row].day);
}
else
{
/* We are supposed to get current timestamp in this row. Just checking that date's got some value */
FAIL_IF(Val[1].day + Val[1].month + Val[1].year == 0, "Date shouldn't be zeroes")
if (tsLen[0] != SQL_NULL_DATA)
{
is_num(tsLen[0], sizeof(SQL_TIMESTAMP_STRUCT));
/* We are supposed to get current timestamp in this row. Just checking that date's got some value */
FAIL_IF(Val[1].day + Val[1].month + Val[1].year == 0, "Date shouldn't be zeroes")
}
}

is_num(idBuf, id[row]);
Expand Down
6 changes: 3 additions & 3 deletions test/datetime.c
Expand Up @@ -724,12 +724,12 @@ ODBC_TEST(t_bug9927)
OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS t_bug9927");
OK_SIMPLE_STMT(Stmt,
"CREATE TABLE t_bug9927 (a TIMESTAMP DEFAULT 0,"
"b TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)");
"b TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)");

/* Not sure which exactly version that was introduced, but 10.11.2 is first ga */
CHECK_STMT_RC(Stmt, SQLSpecialColumns(Stmt,SQL_ROWVER, NULL, 0,
NULL, 0, (SQLCHAR *)"t_bug9927", SQL_NTS,
0, SQL_NO_NULLS));

0, ServerNotOlderThan(Connection, 10,11,2) ? SQL_NULLABLE : SQL_NO_NULLS));
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));

IS_STR(my_fetch_str(Stmt, col, 2), "b", 1);
Expand Down
11 changes: 6 additions & 5 deletions test/error.c
Expand Up @@ -677,15 +677,17 @@ ODBC_TEST(t_odbc94)
SQLHANDLE henv1;
SQLHANDLE Connection1;
SQLHANDLE Stmt1;
SQLCHAR conn[512];
SQLCHAR conn[512], *Query= (SQLCHAR*)"GRANT ALL PRIVILEGES on odbc94 to public";
SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
SQLINTEGER error;
SQLSMALLINT len;

if (ServerNotOlderThan(Connection, 5, 7, 0) == FALSE)
/* Looking at the patch, I'd say any error would be good for the testcase, but leaving original query used in the testcase by default */
if (ServerNotOlderThan(Connection, 5, 7, 0) == FALSE || ServerNotOlderThan(Connection, 10, 11, 2))
{
skip("The test doesn't make sense in pre-10.0 servers, as the target query won't cause in 5.5(or pre-MySQL-5.7 the error it tests");
/*skip("The test doesn't make sense in pre-10.0 servers, as the target query won't cause in 5.5(or pre-MySQL-5.7 the error it tests");*/
Query= (SQLCHAR*)"INSERT INTO non_existent_odbc94 values(1)";
}
sprintf((char *)conn, "DRIVER=%s;SERVER=%s;UID=%s;PASSWORD=%s;DATABASE=%s;%s;%s",
my_drivername, my_servername, my_uid, my_pwd, my_schema, ma_strport, add_connstr);
Expand All @@ -698,8 +700,7 @@ ODBC_TEST(t_odbc94)
NULL, SQL_DRIVER_NOPROMPT));
CHECK_DBC_RC(Connection1, SQLAllocHandle(SQL_HANDLE_STMT, Connection1, &Stmt1));

EXPECT_STMT(Stmt1, SQLExecDirect(Stmt1, (SQLCHAR*)"GRANT ALL PRIVILEGES on odbc94 to public", SQL_NTS), SQL_ERROR);

EXPECT_STMT(Stmt1, SQLExecDirect(Stmt1, Query, SQL_NTS), SQL_ERROR);
CHECK_STMT_RC(Stmt, SQLGetDiagRec(SQL_HANDLE_STMT, Stmt1, 1, sqlstate, &error,
message, sizeof(message), &len));

Expand Down

0 comments on commit 2168db0

Please sign in to comment.