Skip to content

Commit

Permalink
Fixed connection procedure call in couple of tests, since 1 parameter
Browse files Browse the repository at this point in the history
type was changed in previous commit, and these references were
overlooked.
Changed in travis' script ODBCINI and ODBCSYSINI initialization to use
PWD(not sure why:)). Added env var export for tests to detect Travis.
Skipping connstring in Travis. I'd say this is harmless - it is kinda a
special testsuite, and also to check if that is simply a linking problem(libodbcinst.so is the suspect).
Fixed SQL_API SQLTablePrivilegesW - it would always return empty
resultset in CatalogName is NULL. That was not intended, and its ANSI
counterpart doesn't behave like that. Need to file bug report about
that. But I suspect other catalog functions have the same problem.
  • Loading branch information
lawrinn committed Dec 5, 2017
1 parent d9c0ff4 commit c077544
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
18 changes: 10 additions & 8 deletions odbc_3_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3126,23 +3126,25 @@ SQLRETURN SQL_API SQLTablePrivilegesW(SQLHSTMT StatementHandle,
MADB_Stmt *Stmt= (MADB_Stmt *)StatementHandle;
SQLRETURN ret;
char *CpCatalog= NULL,
*CpSchema= NULL,
*CpTable= NULL;
SQLULEN CpLength1, CpLength2, CpLength3;
SQLULEN CpLength1= 0, CpLength3= 0;

if (!Stmt)
return SQL_INVALID_HANDLE;
MADB_CLEAR_ERROR(&Stmt->Error);

CpCatalog= MADB_ConvertFromWChar(CatalogName, NameLength1, &CpLength1, &Stmt->Connection->charset, NULL);
CpSchema= MADB_ConvertFromWChar(SchemaName, NameLength2, &CpLength2, &Stmt->Connection->charset, NULL);
CpTable= MADB_ConvertFromWChar(TableName, NameLength3, &CpLength3, &Stmt->Connection->charset, NULL);
if (CatalogName != NULL)
{
CpCatalog= MADB_ConvertFromWChar(CatalogName, NameLength1, &CpLength1, &Stmt->Connection->charset, NULL);
}
if (TableName != NULL)
{
CpTable= MADB_ConvertFromWChar(TableName, NameLength3, &CpLength3, &Stmt->Connection->charset, NULL);
}

ret= Stmt->Methods->TablePrivileges(Stmt, CpCatalog, (SQLSMALLINT)CpLength1, CpSchema, (SQLSMALLINT)CpLength2,
CpTable, (SQLSMALLINT)CpLength3);
ret= Stmt->Methods->TablePrivileges(Stmt, CpCatalog, (SQLSMALLINT)CpLength1, NULL, 0, CpTable, (SQLSMALLINT)CpLength3);

MADB_FREE(CpCatalog);
MADB_FREE(CpSchema);
MADB_FREE(CpTable);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion test/catalog1.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ ODBC_TEST(t_sqltables)
}

AllocEnvConn(&Env, &hdbc1);
Stmt1= DoConnect(&hdbc1, NULL, NULL, NULL, 0, "mariadbodbc_sqltables", 0, NULL, NULL);
Stmt1= DoConnect(hdbc1, NULL, NULL, NULL, 0, "mariadbodbc_sqltables", 0, NULL, NULL);
FAIL_IF(Stmt1 == NULL, "");

OK_SIMPLE_STMT(Stmt1, "CREATE TABLE t1 (a int)");
Expand Down
5 changes: 3 additions & 2 deletions test/catalog2.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ ODBC_TEST(t_bug50195)
OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS bug50195");
OK_SIMPLE_STMT(Stmt, "CREATE TABLE bug50195 (i INT NOT NULL)");

if (Travis)
if (Travis != 0)
{
diag("Test is run in Travis");
SQLExecDirect(Stmt, (SQLCHAR *)"DROP USER bug50195@'%'", SQL_NTS);
Expand Down Expand Up @@ -312,8 +312,9 @@ ODBC_TEST(t_bug50195)
OK_SIMPLE_STMT(Stmt, "DROP USER bug50195@127.0.0.1");
OK_SIMPLE_STMT(Stmt, "DROP USER bug50195@localhost");
}

OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS bug50195");

return FAIL;
}

CHECK_STMT_RC(hstmt1, SQLTablePrivileges(hstmt1, NULL, 0, 0, 0, "bug50195", SQL_NTS));
Expand Down
5 changes: 5 additions & 0 deletions test/connstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ int main(int argc, char **argv)
{
int ret, tests= sizeof(my_tests)/sizeof(MA_ODBC_TESTS) - 1;

if (Travis)
{
diag("Skipping this testsuite in Travis");
return 0;
}
get_options(argc, argv);
plan(tests);
Dsn= MADB_DSN_Init();
Expand Down
2 changes: 1 addition & 1 deletion test/multistatement.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ODBC_TEST(t_odbc74)
OK_SIMPLE_STMT(Stmt, "TRUNCATE TABLE odbc74");

AllocEnvConn(&Env, &hdbc1);
Stmt1= DoConnect(&hdbc1, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL);
Stmt1= DoConnect(hdbc1, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL);
FAIL_IF(Stmt1 == NULL, "Could not connect and/or allocate");

OK_SIMPLE_STMT(Stmt1, "SET @@SESSION.sql_mode='NO_BACKSLASH_ESCAPES'");
Expand Down
3 changes: 2 additions & 1 deletion test/tap.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ int run_tests(MA_ODBC_TESTS *tests)
wdrivername= str2sqlwchar_on_gbuff(my_drivername, strlen(my_drivername) + 1, utf8, utf16);
wstrport= str2sqlwchar_on_gbuff(ma_strport, strlen(ma_strport) + 1, utf8, utf16);

if (getenv("TRAVIS") != NULL)
/* MAODBCTESTS_IN_TRAVIS is exported by our travis script. TRAVIS and TRAVIS_JOB_ID did not work */
if (getenv("MAODBCTESTS_IN_TRAVIS") != NULL)
{
Travis= 1;
}
Expand Down

0 comments on commit c077544

Please sign in to comment.