@@ -293,6 +293,66 @@ public void testManageDatabase() {
293293 }
294294 }
295295
296+ @ Test
297+ public void testShowCreateDatabase () throws SQLException {
298+ try (final Connection connection =
299+ EnvFactory .getEnv ().getConnection (BaseEnv .TABLE_SQL_DIALECT );
300+ final Statement statement = connection .createStatement ()) {
301+ statement .execute (
302+ "create database test_show_create_db with (ttl=300, max_schema_region_group_num=DEFAULT, max_data_region_group_num=DEFAULT, time_partition_interval=100000)" );
303+
304+ try (final ResultSet resultSet =
305+ statement .executeQuery ("show create database test_show_create_db" )) {
306+ assertTrue (resultSet .next ());
307+ assertEquals ("test_show_create_db" , resultSet .getString ("Database" ));
308+ final String createDatabaseSQL = resultSet .getString ("Create Database" );
309+ assertTrue (
310+ createDatabaseSQL ,
311+ createDatabaseSQL .startsWith ("CREATE DATABASE \" test_show_create_db\" WITH (" ));
312+ assertTrue (createDatabaseSQL , createDatabaseSQL .contains ("ttl=300" ));
313+ assertTrue (createDatabaseSQL , createDatabaseSQL .contains ("time_partition_interval=100000" ));
314+ assertTrue (createDatabaseSQL , createDatabaseSQL .contains ("max_schema_region_group_num=" ));
315+ assertTrue (createDatabaseSQL , createDatabaseSQL .contains ("max_data_region_group_num=" ));
316+ assertFalse (resultSet .next ());
317+ }
318+ }
319+ }
320+
321+ @ Test
322+ public void testShowCreatePipe () throws SQLException {
323+ try (final Connection connection =
324+ EnvFactory .getEnv ().getConnection (BaseEnv .TABLE_SQL_DIALECT );
325+ final Statement statement = connection .createStatement ()) {
326+ statement .execute ("create pipe test_show_create_pipe ('sink'='do-nothing-sink')" );
327+
328+ TestUtils .assertResultSetEqual (
329+ statement .executeQuery ("show create pipe test_show_create_pipe" ),
330+ "Pipe,Create Pipe," ,
331+ Collections .singleton (
332+ "test_show_create_pipe,CREATE PIPE \" test_show_create_pipe\" WITH SINK ('sink'='do-nothing-sink')," ));
333+ }
334+ }
335+
336+ @ Test
337+ public void testShowCreateInformationSchemaDatabase () throws SQLException {
338+ try (final Connection connection =
339+ EnvFactory .getEnv ().getConnection (BaseEnv .TABLE_SQL_DIALECT );
340+ final Statement statement = connection .createStatement ()) {
341+ assertShowCreateSystemDatabaseFails (statement , "information_schema" );
342+ assertShowCreateSystemDatabaseFails (statement , "__audit" );
343+ }
344+ }
345+
346+ private static void assertShowCreateSystemDatabaseFails (
347+ final Statement statement , final String database ) throws SQLException {
348+ try {
349+ statement .executeQuery ("show create database " + database );
350+ fail ("show create database " + database + " shouldn't succeed" );
351+ } catch (final SQLException e ) {
352+ assertEquals ("701: The system database does not support show create." , e .getMessage ());
353+ }
354+ }
355+
296356 @ Test
297357 public void testDatabaseWithSpecificCharacters () throws SQLException {
298358 try (final Connection connection =
0 commit comments