forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](catalog) should return error if try using a unknown database (a…
- Loading branch information
1 parent
63868b4
commit 9b1f290
Showing
9 changed files
with
168 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
regression-test/data/external_table_p0/jdbc/test_jdbc_catalog_ddl.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !show_db -- | ||
DORIS | ||
Doris | ||
doris | ||
doris_test | ||
information_schema | ||
init_db | ||
mysql | ||
show_test_do_not_modify | ||
|
||
-- !sql01 -- | ||
12345 | ||
|
||
-- !show_db -- | ||
DORIS | ||
Doris | ||
doris | ||
doris_test | ||
information_schema | ||
init_db | ||
mysql | ||
show_test_do_not_modify | ||
|
||
-- !sql01 -- | ||
12345 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
regression-test/suites/external_table_p0/jdbc/test_jdbc_catalog_ddl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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. | ||
|
||
suite("test_jdbc_catalog_ddl", "p0,external,mysql,external_docker,external_docker_mysql") { | ||
|
||
String enabled = context.config.otherConfigs.get("enableJdbcTest") | ||
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp") | ||
String s3_endpoint = getS3Endpoint() | ||
String bucket = getS3BucketName() | ||
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-java-5.1.49.jar" | ||
String mysql_port = context.config.otherConfigs.get("mysql_57_port"); | ||
// String driver_url = "mysql-connector-java-5.1.49.jar" | ||
if (enabled != null && enabled.equalsIgnoreCase("true")) { | ||
String catalog_name = "mysql_jdbc5_catalog"; | ||
|
||
for (String useMetaCache : ["true", "false"]) { | ||
sql """drop catalog if exists ${catalog_name} """ | ||
sql """create catalog if not exists ${catalog_name} properties( | ||
"type"="jdbc", | ||
"user"="root", | ||
"password"="123456", | ||
"jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}/doris_test?useSSL=false&zeroDateTimeBehavior=convertToNull", | ||
"driver_url" = "${driver_url}", | ||
"driver_class" = "com.mysql.jdbc.Driver", | ||
"use_meta_cache" = "${useMetaCache}" | ||
);""" | ||
order_qt_show_db """ show databases from ${catalog_name}; """ | ||
|
||
// test wrong catalog and db | ||
test { | ||
sql """switch unknown_catalog""" | ||
exception "Unknown catalog 'unknown_catalog'" | ||
} | ||
test { | ||
sql """use unknown_catalog.db1""" | ||
exception """Unknown catalog 'unknown_catalog'""" | ||
} | ||
test { | ||
sql """use ${catalog_name}.unknown_db""" | ||
exception """Unknown database 'unknown_db'""" | ||
} | ||
|
||
// create a database in mysql | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists temp_database")""" | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "create database temp_database")""" | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "drop table if exists temp_database.temp_table")""" | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "create table temp_database.temp_table (k1 int)")""" | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "insert into temp_database.temp_table values(12345)")""" | ||
|
||
if (useMetaCache.equals("false")) { | ||
sql """refresh catalog ${catalog_name}""" | ||
} | ||
sql "use ${catalog_name}.temp_database" | ||
qt_sql01 """select * from temp_table""" | ||
sql """CALL EXECUTE_STMT("${catalog_name}", "drop database if exists temp_database")""" | ||
} | ||
} | ||
} | ||
|