Skip to content

Commit

Permalink
ODBC-324 SQLTables would not show versioned tables
Browse files Browse the repository at this point in the history
That affected Excel, and must also did Accept. As well as any other
application browsing tables in a MariaDB DB.
Versioned tables have special table type in infromation schema, and thus
did not appear in the query results.
  • Loading branch information
lawrinn committed Jul 30, 2021
1 parent 8ce387a commit 6fcd1b9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ma_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ SQLRETURN MADB_StmtTables(MADB_Stmt *Stmt, char *CatalogName, SQLSMALLINT Catalo
else
{
MADB_InitDynamicString(&StmtStr, "SELECT TABLE_SCHEMA AS TABLE_CAT, NULL AS TABLE_SCHEM, TABLE_NAME, "
"if(TABLE_TYPE='BASE TABLE','TABLE',TABLE_TYPE) AS TABLE_TYPE ,"
"if(TABLE_TYPE='BASE TABLE' OR TABLE_TYPE='SYSTEM VERSIONED','TABLE',TABLE_TYPE) AS TABLE_TYPE ,"
"TABLE_COMMENT AS REMARKS FROM INFORMATION_SCHEMA.TABLES WHERE 1=1 ",
8192, 512);

Expand Down Expand Up @@ -355,7 +355,7 @@ SQLRETURN MADB_StmtTables(MADB_Stmt *Stmt, char *CatalogName, SQLSMALLINT Catalo
if (strstr(TableType, myTypes[i]))
{
if (strstr(myTypes[i], "TABLE"))
MADB_DYNAPPENDCONST(&StmtStr, ", 'BASE TABLE'");
MADB_DYNAPPENDCONST(&StmtStr, ", 'BASE TABLE', 'SYSTEM VERSIONED'");
else
{
MADB_DYNAPPENDCONST(&StmtStr, ", '");
Expand Down
2 changes: 0 additions & 2 deletions ma_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ MADB_FixIrdRecord(MADB_Stmt *Stmt, MADB_DescRecord *Record)
MADB_FixDisplaySize(Record, &cs);
MADB_FixDataSize(Record, &cs);

/*Record->TypeName= strdup(MADB_GetTypeName(Fields[i]));*/

switch(Record->ConciseType) {
case SQL_BINARY:
case SQL_VARBINARY:
Expand Down
25 changes: 25 additions & 0 deletions test/catalog2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,30 @@ ODBC_TEST(odbc316)
}


ODBC_TEST(odbc324)
{
SQLCHAR tableType[32];

OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS t_odbc324");
OK_SIMPLE_STMT(Stmt, "CREATE TABLE t_odbc324 (id int not null) WITH SYSTEM VERSIONING");

/* It doesn't matter if we call SQLColumns or SQLColumnsW */
CHECK_STMT_RC(Stmt, SQLTables(Stmt, my_schema, SQL_NTS, NULL, 0,
"t_odbc324", SQL_NTS, "TABLE,VIEW", SQL_NTS));

CHECK_STMT_RC(Stmt, SQLFetch(Stmt));

IS_STR("TABLE", my_fetch_str(Stmt, tableType, 4), sizeof("TABLE"));
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA_FOUND);

CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

OK_SIMPLE_STMT(Stmt, "DROP TABLE t_odbc324");

return OK;
}


MA_ODBC_TESTS my_tests[]=
{
{t_bug37621, "t_bug37621", NORMAL},
Expand Down Expand Up @@ -1790,6 +1814,7 @@ MA_ODBC_TESTS my_tests[]=
{odbc231, "odbc231_sqlcolumns_longtext", NORMAL},
{odbc313, "odbc313_no_patterns_for_sqlpkeys", NORMAL},
{odbc316, "odbc316_empty_string_parameters", NORMAL},
{odbc324, "odbc324_sqltables_versioned_table",NORMAL},
{NULL, NULL}
};

Expand Down

0 comments on commit 6fcd1b9

Please sign in to comment.