[#7087] Support USE for SET SCHEMA in Derby and HSQLDB

This commit is contained in:
lukaseder 2018-01-25 16:31:12 +01:00
parent cbfd3bb6ee
commit 0e12b3fa6e
5 changed files with 17 additions and 7 deletions

View File

@ -171,7 +171,10 @@ renameStatement = 'RENAME'
setCatalogStatement = 'SET CATALOG' catalogName
;
setSchemaStatement = 'SET SCHEMA' schemaName
setSchemaStatement = 'SET' (
[ 'CURRENT' ] 'SCHEMA'
| 'CURRENT SQLID'
) [ '=' ] ( schemaName | stringLiteral )
;
useStatement = 'USE' ( catalogName | schemaName )

View File

@ -8488,7 +8488,7 @@ public interface DSLContext extends Scope , AutoCloseable {
*
* @see DSL#schema(Name)
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Query setSchema(String schema);
/**
@ -8496,13 +8496,13 @@ public interface DSLContext extends Scope , AutoCloseable {
*
* @see DSL#schema(Name)
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Query setSchema(Name schema);
/**
* Set the current schema to a new value.
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Query setSchema(Schema schema);
// -------------------------------------------------------------------------

View File

@ -6648,7 +6648,7 @@ public class DSL {
*
* @see DSL#schema(Name)
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
public static Query setSchema(String schema) {
return dsl().setSchema(schema);
}
@ -6658,7 +6658,7 @@ public class DSL {
*
* @see DSL#schema(Name)
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
public static Query setSchema(Name schema) {
return dsl().setSchema(schema);
}
@ -6666,7 +6666,7 @@ public class DSL {
/**
* Set the current schema to a new value.
*/
@Support({ H2, MARIADB, MYSQL, POSTGRES} )
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
public static Query setSchema(Schema schema) {
return dsl().setSchema(schema);
}

View File

@ -1249,6 +1249,10 @@ final class ParserImpl implements Parser {
if (parseKeywordIf(ctx, "CATALOG"))
return parseSetCatalog(ctx);
else if (parseKeywordIf(ctx, "CURRENT SCHEMA"))
return parseSetSchema(ctx);
else if (parseKeywordIf(ctx, "CURRENT SQLID"))
return parseSetSchema(ctx);
else if (parseKeywordIf(ctx, "GENERATOR"))
return parseSetGenerator(ctx);
else if (parseKeywordIf(ctx, "SCHEMA"))
@ -1271,6 +1275,7 @@ final class ParserImpl implements Parser {
}
private static final Query parseSetSchema(ParserContext ctx) {
parseIf(ctx, '=');
return ctx.dsl.setSchema(parseSchemaName(ctx));
}

View File

@ -77,7 +77,9 @@ final class SetSchema extends AbstractQuery {
ctx.visit(K_USE).sql(' ').visit(schema);
break;
case DERBY:
case H2:
case HSQLDB:
case POSTGRES:
default:
ctx.visit(K_SET).sql(' ').visit(K_SCHEMA).sql(' ').visit(schema);