Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
import com.oceanbase.tools.dbbrowser.util.StringUtils;

/**
* 适配 MySQL 版本:[5.7.00, ~)
*
* @author jingtian
*/
public class MySQLNoGreaterThan5740IndexEditor extends DBTableIndexEditor {
public class MySQLNoLessThan5700IndexEditor extends DBTableIndexEditor {

@Override
protected void appendIndexColumnModifiers(DBTableIndex index, SqlBuilder sqlBuilder) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @Date: 2022/7/19 下午5:04
* @Description: []
*/
public class OBMySQLIndexEditor extends MySQLNoGreaterThan5740IndexEditor {
public class OBMySQLIndexEditor extends MySQLNoLessThan5700IndexEditor {


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class DBSchemaAccessorSqlMappers {
StatementsFiles.OBMYSQL_2276,
StatementsFiles.OBMYSQL_225X,
StatementsFiles.OBMYSQL_1479,
StatementsFiles.MYSQL_5_7_40,
StatementsFiles.MYSQL_5_7_x,
StatementsFiles.MYSQL_5_6_x,
StatementsFiles.OBORACLE_3_x,
StatementsFiles.OBORACLE_4_0_x,
StatementsFiles.ORACLE_11_g));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public final class StatementsFiles {

public static final String OBMYSQL_1479 = "schema/sql/obmysql/obmysql_1_4_79.yaml";

public static final String MYSQL_5_7_40 = "schema/sql/mysql/mysql_5_7_40.yaml";
public static final String MYSQL_5_7_x = "schema/sql/mysql/mysql_5_7_x.yaml";

public static final String MYSQL_5_6_x = "schema/sql/mysql/mysql_5_6_x.yaml";

public static final String OBORACLE_4_0_x = "schema/sql/oboracle/oboracle_4_0_x.yaml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class DorisSchemaAccessor implements DBSchemaAccessor {

public DorisSchemaAccessor(@NonNull JdbcOperations jdbcOperations) {
this.jdbcOperations = jdbcOperations;
this.sqlMapper = DBSchemaAccessorSqlMappers.get(StatementsFiles.MYSQL_5_7_40);
this.sqlMapper = DBSchemaAccessorSqlMappers.get(StatementsFiles.MYSQL_5_7_x);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.oceanbase.tools.dbbrowser.schema.mysql;

import org.springframework.jdbc.core.JdbcOperations;

import com.oceanbase.tools.dbbrowser.schema.DBSchemaAccessorSqlMappers;
import com.oceanbase.tools.dbbrowser.schema.constant.StatementsFiles;

/**
*
* {@link MySQLNoLessThan5600SchemaAccessor}
*
* 适配 MySQL 版本:[5.6.00, 5.7.00)
*
* @author jingtian
* @date 2024/2/26
* @since ODC_release_4.2.4
*/
public class MySQLNoLessThan5600SchemaAccessor extends MySQLNoLessThan5700SchemaAccessor {
public MySQLNoLessThan5600SchemaAccessor(JdbcOperations jdbcOperations) {
super(jdbcOperations);
this.sqlMapper = DBSchemaAccessorSqlMappers.get(StatementsFiles.MYSQL_5_6_x);
}

@Override
protected boolean supportGeneratedColumn() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@
import lombok.extern.slf4j.Slf4j;

/**
* {@link MySQLNoGreaterThan5740SchemaAccessor}
* {@link MySQLNoLessThan5700SchemaAccessor}
*
* 适配 MySQL 版本:(~, 5.7.40]
* 适配 MySQL 版本:[5.7.00, ~)
*/
@Slf4j
public class MySQLNoGreaterThan5740SchemaAccessor implements DBSchemaAccessor {
public class MySQLNoLessThan5700SchemaAccessor implements DBSchemaAccessor {

protected JdbcOperations jdbcOperations;
protected DBSchemaAccessorSqlMapper sqlMapper;

public MySQLNoGreaterThan5740SchemaAccessor(@NonNull JdbcOperations jdbcOperations) {
public MySQLNoLessThan5700SchemaAccessor(@NonNull JdbcOperations jdbcOperations) {
this.jdbcOperations = jdbcOperations;
this.sqlMapper = DBSchemaAccessorSqlMappers.get(StatementsFiles.MYSQL_5_7_40);
this.sqlMapper = DBSchemaAccessorSqlMappers.get(StatementsFiles.MYSQL_5_7_x);
}

@Override
Expand Down Expand Up @@ -499,7 +499,9 @@ protected RowMapper<DBTableColumn> listTableRowMapper() {
tableColumn.setComment(rs.getString(MySQLConstants.COL_COLUMN_COMMENT));
tableColumn.fillDefaultValue(rs.getString(MySQLConstants.COL_COLUMN_DEFAULT));
tableColumn.setNullable("YES".equalsIgnoreCase(rs.getString(MySQLConstants.COL_IS_NULLABLE)));
tableColumn.setGenExpression(rs.getString(MySQLConstants.COL_COLUMN_GENERATION_EXPRESSION));
if (supportGeneratedColumn()) {
tableColumn.setGenExpression(rs.getString(MySQLConstants.COL_COLUMN_GENERATION_EXPRESSION));
}
tableColumn.setVirtual(StringUtils.isNotEmpty(tableColumn.getGenExpression()));
tableColumn.setOrdinalPosition(rs.getInt(MySQLConstants.COL_ORDINAL_POSITION));
String keyTypeName = rs.getString(MySQLConstants.COL_COLUMN_KEY);
Expand Down Expand Up @@ -536,6 +538,10 @@ protected RowMapper<DBTableColumn> listTableRowMapper() {
};
}

protected boolean supportGeneratedColumn() {
return true;
}

protected RowMapper<DBTableColumn> listBasicTableColumnRowMapper() {
return (rs, romNum) -> {
DBTableColumn tableColumn = new DBTableColumn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* @author jingtian
*/
@Slf4j
public class OBMySQLSchemaAccessor extends MySQLNoGreaterThan5740SchemaAccessor {
public class OBMySQLSchemaAccessor extends MySQLNoLessThan5700SchemaAccessor {

protected static final Set<String> ESCAPE_SCHEMA_SET = new HashSet<>(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* @author jingtian
*/
public class ODPOBMySQLSchemaAccessor extends MySQLNoGreaterThan5740SchemaAccessor {
public class ODPOBMySQLSchemaAccessor extends MySQLNoLessThan5700SchemaAccessor {

public ODPOBMySQLSchemaAccessor(JdbcOperations jdbcOperations) {
super(jdbcOperations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @Create 2024/2/5 16:23
* @Version 1.0
*/
public class DorisStatsAccessor extends MySQLNoGreaterThan5740StatsAccessor {
public class DorisStatsAccessor extends MySQLNoLessThan5700StatsAccessor {
public DorisStatsAccessor(@NonNull JdbcOperations jdbcOperations) {
super(jdbcOperations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import lombok.NonNull;

/**
* {@link MySQLNoGreaterThan5740StatsAccessor}
* {@link MySQLNoLessThan5700StatsAccessor}
*
* 适配 MySQL 版本:(~, 5.7.40]
* 适配 MySQL 版本:[5.7.00, ~)
*/
public class MySQLNoGreaterThan5740StatsAccessor implements DBStatsAccessor {
public class MySQLNoLessThan5700StatsAccessor implements DBStatsAccessor {
private static final String QUERY_SESSION_FROM_PROCESSLIST = "SELECT `ID`, "
+ "`USER` as USERNAME, "
+ "`DB` as DATABASE_NAME, "
Expand All @@ -56,7 +56,7 @@ public class MySQLNoGreaterThan5740StatsAccessor implements DBStatsAccessor {

final JdbcOperations jdbcOperations;

public MySQLNoGreaterThan5740StatsAccessor(@NonNull JdbcOperations jdbcOperations) {
public MySQLNoLessThan5700StatsAccessor(@NonNull JdbcOperations jdbcOperations) {
this.jdbcOperations = jdbcOperations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @date 2022-11-09 15:02
* @since ODC_release_4.1.0
*/
public class OBMySQLStatsAccessor extends MySQLNoGreaterThan5740StatsAccessor {
public class OBMySQLStatsAccessor extends MySQLNoLessThan5700StatsAccessor {

public OBMySQLStatsAccessor(@NonNull JdbcOperations jdbcOperations) {
super(jdbcOperations);
Expand Down
183 changes: 183 additions & 0 deletions libs/db-browser/src/main/resources/schema/sql/mysql/mysql_5_6_x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
sqls:
list-basic-table-columns: |-
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE,
COLUMN_COMMENT
FROM
information_schema.columns
WHERE
TABLE_SCHEMA = ? AND TABLE_NAME = ?
ORDER BY
ORDINAL_POSITION ASC
list-basic-schema-table-columns: |-
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE,
COLUMN_COMMENT
FROM
information_schema.columns
WHERE
TABLE_SCHEMA = ?
AND TABLE_NAME IN (
SELECT
TABLE_NAME
FROM
information_schema.tables
WHERE
TABLE_SCHEMA = ? AND TABLE_TYPE = 'BASE TABLE'
)
ORDER BY
TABLE_NAME ASC,
ORDINAL_POSITION ASC
list-basic-view-columns: |-
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE,
COLUMN_COMMENT
FROM
information_schema.columns
WHERE
TABLE_SCHEMA = ? AND TABLE_NAME = ?
ORDER BY
ORDINAL_POSITION ASC
list-basic-schema-view-columns: |-
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE,
COLUMN_COMMENT
FROM
information_schema.columns
WHERE
TABLE_SCHEMA = ?
AND TABLE_NAME IN (
SELECT
TABLE_NAME
FROM
information_schema.tables
WHERE
TABLE_SCHEMA = ? AND TABLE_TYPE = 'VIEW'
)
ORDER BY
TABLE_NAME ASC,
ORDINAL_POSITION ASC
list-table-columns: |-
SELECT
TABLE_NAME,
TABLE_SCHEMA,
ORDINAL_POSITION,
COLUMN_NAME,
DATA_TYPE,
COLUMN_TYPE,
NUMERIC_SCALE,
NUMERIC_PRECISION,
DATETIME_PRECISION,
NUMERIC_SCALE,
CHARACTER_MAXIMUM_LENGTH,
EXTRA,
CHARACTER_SET_NAME,
COLLATION_NAME,
COLUMN_COMMENT,
COLUMN_DEFAULT,
IS_NULLABLE,
COLUMN_KEY
FROM
information_schema.columns
WHERE
TABLE_SCHEMA = ? AND TABLE_NAME = ?
ORDER BY
ORDINAL_POSITION ASC
list-table-constraints: |-
SELECT
t1.CONSTRAINT_NAME,
t1.CONSTRAINT_SCHEMA,
t1.TABLE_NAME,
t1.COLUMN_NAME,
t1.ORDINAL_POSITION,
t1.REFERENCED_TABLE_SCHEMA,
t1.REFERENCED_TABLE_NAME,
t1.REFERENCED_COLUMN_NAME,
t2.CONSTRAINT_TYPE
FROM
information_schema.key_column_usage t1
LEFT JOIN information_schema.table_constraints t2 ON t1.TABLE_NAME = t2.TABLE_NAME
and t1.TABLE_SCHEMA = t2.TABLE_SCHEMA
and t1.CONSTRAINT_NAME = t2.CONSTRAINT_NAME
WHERE
t1.TABLE_SCHEMA = ? AND t1.TABLE_NAME = ?
ORDER BY
t1.CONSTRAINT_NAME,
t1.ORDINAL_POSITION ASC
get-table-option: |-
SELECT
`CREATE_TIME`,
`UPDATE_TIME`,
`AUTO_INCREMENT`,
`TABLE_COLLATION`,
`TABLE_COMMENT`
FROM
`information_schema`.`tables`
WHERE
TABLE_SCHEMA = ? and TABLE_NAME = ?
get-partition: |-
SELECT
PARTITION_NAME,
SUBPARTITION_NAME,
COUNT(SUBPARTITION_NAME) AS SUB_NUM,
PARTITION_ORDINAL_POSITION,
PARTITION_METHOD,
SUBPARTITION_METHOD,
PARTITION_EXPRESSION,
SUBPARTITION_EXPRESSION,
PARTITION_DESCRIPTION
FROM
information_schema.partitions
WHERE
TABLE_SCHEMA = ? AND TABLE_NAME = ?
GROUP BY
PARTITION_NAME
ORDER BY
PARTITION_NAME ASC
list-partitions: |-
SELECT
PARTITION_NAME as PARTITION_NAME,
SUBPARTITION_NAME as SUBPARTITION_NAME,
PARTITION_ORDINAL_POSITION as PARTITION_ORDINAL_POSITION,
PARTITION_METHOD as PARTITION_METHOD,
SUBPARTITION_METHOD as SUBPARTITION_METHOD,
PARTITION_EXPRESSION as PARTITION_EXPRESSION,
SUBPARTITION_EXPRESSION as SUBPARTITION_EXPRESSION,
PARTITION_DESCRIPTION as PARTITION_DESCRIPTION,
TABLE_NAME as TABLE_NAME
FROM
information_schema.partitions
WHERE
TABLE_SCHEMA = ? AND PARTITION_NAME is not null
list-schema-index: |-
SELECT
TABLE_SCHEMA,
TABLE_NAME,
NON_UNIQUE,
INDEX_NAME,
SEQ_IN_INDEX,
COLUMN_NAME,
COLLATION,
CARDINALITY,
SUB_PART,
INDEX_TYPE,
COMMENT,
INDEX_COMMENT
FROM
information_schema.statistics
WHERE TABLE_SCHEMA = ?
ORDER BY
TABLE_NAME,
SEQ_IN_INDEX
Loading