Skip to content

Commit 4fe4e64

Browse files
committed
[ODBC-77] Fix and the testcase. Connector did not recognize ANALYZE
TABLE as query returning result. SImilar error fixed for EXPLAIN.
1 parent 3de37aa commit 4fe4e64

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

ma_parse.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ enum enum_madb_query_type MADB_GetQueryType(MADB_Stmt *Stmt)
168168
{
169169
return MADB_QUERY_SHOW;
170170
}
171+
if (_strnicmp(p, "ANALYZE", 7) == 0)
172+
{
173+
return MADB_QUERY_ANALYZE;
174+
}
175+
if (_strnicmp(p, "EXPLAIN", 7) == 0)
176+
{
177+
return MADB_QUERY_EXPLAIN;
178+
}
179+
if (_strnicmp(p, "CHECK", 5) == 0)
180+
{
181+
return MADB_QUERY_CHECK;
182+
}
183+
if (_strnicmp(p, "EXECUTE", 7) == 0)
184+
{
185+
return MADB_QUERY_EXECUTE;
186+
}
171187

172188
return MADB_QUERY_NO_RESULT;
173189
}

ma_parse.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ enum enum_madb_query_type { MADB_QUERY_NO_RESULT= 0, /* Default type for the que
2727
MADB_QUERY_DELETE= SQL_DELETE,
2828
MADB_QUERY_SELECT,
2929
MADB_QUERY_SHOW,
30-
MADB_QUERY_CALL
30+
MADB_QUERY_CALL,
31+
MADB_QUERY_ANALYZE,
32+
MADB_QUERY_EXPLAIN,
33+
MADB_QUERY_CHECK,
34+
MADB_QUERY_EXECUTE
3135
};
3236

3337
#define QUERY_DOESNT_RETURN_RESULT(query_type) ((query_type) < MADB_QUERY_SELECT)

test/multistatement.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ ODBC_TEST(test_semicolon)
198198
/* Double quote inside single quotes caused error in parsing while*/
199199
ODBC_TEST(t_odbc_74)
200200
{
201-
SQLCHAR ref[][4]={"\"", "'", "*/", "/*", "end"}, val[4];
201+
SQLCHAR ref[][4]={"\"", "'", "*/", "/*", "end", "one", "two"}, val[4];
202202
unsigned int i;
203203

204204
OK_SIMPLE_STMT(Stmt, "DROP TABLE IF EXISTS odbc74; CREATE TABLE odbc74(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,\
@@ -210,6 +210,10 @@ ODBC_TEST(t_odbc_74)
210210
INSERT INTO odbc74 (val) VALUES('/*');-- comment\"'; insert into non_existent values(1)\n\
211211
INSERT INTO odbc74 (val) VALUES('end')\n\
212212
# ;Unhappy comment at the end ");
213+
OK_SIMPLE_STMT(Stmt, "-- comment ;1 \n\
214+
# comment ;2 \n\
215+
INSERT INTO odbc74 (val) VALUES('one');\
216+
INSERT INTO odbc74 (val) VALUES(\"two\");");
213217
OK_SIMPLE_STMT(Stmt, "SELECT val FROM odbc74 ORDER BY id");
214218

215219
for (i= 0; i < sizeof(ref)/sizeof(ref[0]); ++i)

test/result2.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,39 @@ ODBC_TEST(t_odbc58)
10421042
}
10431043

10441044

1045+
ODBC_TEST(t_odbc77)
1046+
{
1047+
OK_SIMPLE_STMT(Stmt, "DROP table if exists t_odbc41");
1048+
1049+
OK_SIMPLE_STMT(Stmt, "ANALYZE TABLE non_existent");
1050+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1051+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1052+
1053+
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA);
1054+
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
1055+
1056+
#ifdef MDEV_11966_FIXED
1057+
OK_SIMPLE_STMT(Stmt, "ANALYZE SELECT 1");
1058+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1059+
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA);
1060+
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
1061+
#endif
1062+
OK_SIMPLE_STMT(Stmt, "EXPLAIN SELECT 1");
1063+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1064+
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA);
1065+
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));
1066+
1067+
/*CHECK is not preparable */
1068+
/*OK_SIMPLE_STMT(Stmt, "CHECK TABLE non_existent");
1069+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1070+
CHECK_STMT_RC(Stmt, SQLFetch(Stmt));
1071+
EXPECT_STMT(Stmt, SQLFetch(Stmt), SQL_NO_DATA);
1072+
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));*/
1073+
1074+
return OK;
1075+
}
1076+
1077+
10451078
MA_ODBC_TESTS my_tests[]=
10461079
{
10471080
{t_bug32420, "t_bug32420"},
@@ -1062,7 +1095,8 @@ MA_ODBC_TESTS my_tests[]=
10621095
{t_bug11766437, "t_bug11766437"},
10631096
{t_odbc29, "t_odbc-29"},
10641097
{t_odbc41, "t_odbc-41-nors_after_rs"},
1065-
{ t_odbc58, "t_odbc-58-numeric_after_blob" },
1098+
{t_odbc58, "t_odbc-58-numeric_after_blob"},
1099+
{t_odbc77, "t_odbc-77-analyze_table"},
10661100
{NULL, NULL}
10671101
};
10681102

0 commit comments

Comments
 (0)