diff --git a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java index 9321e61574..ece499f094 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java +++ b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java @@ -1452,7 +1452,7 @@ final class Interpreter { private final MutableSchema getSchema(Schema input, boolean create, boolean throwIfNotExists) { if (input == null) - return currentSchema(create); + return currentSchema(); MutableCatalog catalog = defaultCatalog; if (input.getCatalog() != null) { @@ -1477,21 +1477,28 @@ final class Interpreter { return schema; } - private final MutableSchema currentSchema(boolean create) { + private final MutableSchema currentSchema() { if (currentSchema == null) - currentSchema = getInterpreterSearchPathSchema(create); + currentSchema = getInterpreterSearchPathSchemas().get(0); return currentSchema; } - private final MutableSchema getInterpreterSearchPathSchema(boolean create) { + private final List getInterpreterSearchPathSchemas() { List searchPath = configuration.settings().getInterpreterSearchPath(); if (searchPath.isEmpty()) - return defaultSchema; + return asList(defaultSchema); - InterpreterSearchSchema schema = searchPath.get(0); - return getSchema(schema(name(schema.getCatalog(), schema.getSchema())), create, false); + List result = new ArrayList<>(); + for (InterpreterSearchSchema schema : searchPath) { + MutableSchema s = getSchema(schema(name(schema.getCatalog(), schema.getSchema())), false, false); + + if (s != null) + result.add(s); + } + + return result; } private final MutableTable newTable( @@ -1535,7 +1542,19 @@ final class Interpreter { } private final MutableTable table(Table table, boolean throwIfNotExists) { - MutableTable result = getSchema(table.getSchema(), false, throwIfNotExists).table(table, true); + MutableTable result = null; + + if (table.getSchema() != null) { + result = getSchema(table.getSchema(), false, throwIfNotExists).table(table, true); + } + else { + for (MutableSchema s : getInterpreterSearchPathSchemas()) { + result = s.table(table, true); + + if (result != null) + break; + } + } if (result == null && throwIfNotExists) throw notExists(table);