Skip to content

Commit

Permalink
bugfix: fixed problem when set useInformationSchema true and table na…
Browse files Browse the repository at this point in the history
…me was keyword (apache#1768)
  • Loading branch information
l81893521 authored and jsbxyyx committed Oct 29, 2019
1 parent 7c66b34 commit 9dab05d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ private TableMeta resultSetMetaToSchema(ResultSetMetaData rsmd, DatabaseMetaData
TableMeta tm = new TableMeta();
tm.setTableName(tableName);

/*
* when set the useInformationSchema true just like jdbc:mysql://127.0.0.1:3306/xxx?useInformationSchema=true
* mysql will use DatabaseMetaDataUsingInfoSchema instead of DatabaseMetaData
* so
* the type of get table meta will change from
* show full columns from xxx from xxx
* to
* select xxx from xxx where catalog_name like ? and table_name like ?
* in the second type we have to remove the "`"
*/
if(tableName.contains("`")){
tableName = tableName.replace("`", "");
}

ResultSet rsColumns = dbmd.getColumns(catalogName, schemaName, tableName, "%");
ResultSet rsIndex = dbmd.getIndexInfo(catalogName, schemaName, tableName, false, true);

Expand Down

0 comments on commit 9dab05d

Please sign in to comment.