[jOOQ/jOOQ#9818] Get view source code from org.jooq.Meta views

This commit is contained in:
Lukas Eder 2023-02-28 16:30:04 +01:00
parent efdf5d98ec
commit 4941d75b59
11 changed files with 319 additions and 17 deletions

View File

@ -75,6 +75,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@ -91,7 +92,6 @@ import org.jooq.ExecuteContext;
import org.jooq.ExecuteListener;
import org.jooq.Field;
import org.jooq.Log;
import org.jooq.Log.Level;
import org.jooq.Meta;
import org.jooq.MetaProvider;
import org.jooq.Name;
@ -3631,7 +3631,24 @@ public abstract class AbstractDatabase implements Database {
* Retrieve ALL source code from the database.
*/
protected Map<Definition, String> getSources0() throws SQLException {
return new LinkedHashMap<>();
Map<Definition, String> result = new LinkedHashMap<>();
if (this instanceof ResultQueryDatabase d) {
Optional
.ofNullable(d.sources(getInputSchemata()))
.ifPresent(q -> q.forEach(r -> {
SchemaDefinition schema = getSchema(r.value2());
if (schema != null) {
Definition view = getTable(schema, r.value3());
if (view != null)
result.put(view, r.value4());
}
}));
}
return result;
}
/**

View File

@ -42,9 +42,11 @@ import java.util.List;
import org.jooq.Meta;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record6;
import org.jooq.ResultQuery;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ApiStatus.Internal;
/**
@ -72,8 +74,11 @@ public interface ResultQueryDatabase extends Database {
* <li>Column name</li>
* <li>Column sequence</li>
* </ol>
*
* @return The query or <code>null</code> if this implementation doesn't support the query.
*/
@Internal
@Nullable
ResultQuery<Record6<String, String, String, String, String, Integer>> primaryKeys(List<String> schemas);
/**
@ -89,8 +94,11 @@ public interface ResultQueryDatabase extends Database {
* <li>Column name</li>
* <li>Column sequence</li>
* </ol>
*
* @return The query or <code>null</code> if this implementation doesn't support the query.
*/
@Internal
@Nullable
ResultQuery<Record6<String, String, String, String, String, Integer>> uniqueKeys(List<String> schemas);
/**
@ -111,7 +119,27 @@ public interface ResultQueryDatabase extends Database {
* <li>Cycle</li>
* <li>Cache</li>
* </ol>
*
* @return The query or <code>null</code> if this implementation doesn't support the query.
*/
@Internal
@Nullable
ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas);
/**
* A query that produces source code for a set of input schemas.
* <p>
* The resulting columns are:
* <ol>
* <li>Catalog name</li>
* <li>Schema name</li>
* <li>Object name (e.g. table, view, function, package)</li>
* <li>Source</li>
* </ol>
*
* @return The query or <code>null</code> if this implementation doesn't support the query.
*/
@Internal
@Nullable
ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas);
}

View File

@ -75,6 +75,7 @@ import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Result;
@ -352,6 +353,24 @@ public class DerbyDatabase extends AbstractDatabase implements ResultQueryDataba
.collect(mapping(r -> new SchemaDefinition(this, r.value1(), ""), toList()));
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
inline(null, VARCHAR).cast(VARCHAR).as("catalog"),
SYSTABLES.sysschemas().SCHEMANAME,
SYSTABLES.TABLENAME,
SYSVIEWS.VIEWDEFINITION)
.from(SYSTABLES)
.leftJoin(SYSVIEWS)
.on(SYSTABLES.TABLEID.eq(SYSVIEWS.TABLEID))
// [#6797] The cast is necessary if a non-standard collation is used
.where(SYSTABLES.sysschemas().SCHEMANAME.cast(VARCHAR(32672)).in(schemas))
.orderBy(
SYSTABLES.sysschemas().SCHEMANAME,
SYSTABLES.TABLENAME);
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
return create().select(

View File

@ -385,6 +385,18 @@ public class FirebirdDatabase extends AbstractDatabase implements ResultQueryDat
return result;
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
inline(null, VARCHAR).as("catalog"),
inline(null, VARCHAR).as("schema"),
RDB$RELATIONS.RDB$RELATION_NAME.trim(),
RDB$RELATIONS.RDB$VIEW_SOURCE.trim())
.from(RDB$RELATIONS)
.orderBy(RDB$RELATIONS.RDB$RELATION_NAME.trim());
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
return create()

View File

@ -46,7 +46,6 @@ import static org.jooq.impl.DSL.arrayAgg;
import static org.jooq.impl.DSL.coalesce;
import static org.jooq.impl.DSL.concat;
import static org.jooq.impl.DSL.condition;
import static org.jooq.impl.DSL.exists;
import static org.jooq.impl.DSL.falseCondition;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.inline;
@ -54,7 +53,6 @@ import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.noCondition;
import static org.jooq.impl.DSL.not;
import static org.jooq.impl.DSL.nullif;
import static org.jooq.impl.DSL.nvl;
import static org.jooq.impl.DSL.one;
import static org.jooq.impl.DSL.row;
import static org.jooq.impl.DSL.select;
@ -88,7 +86,6 @@ import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -140,7 +137,6 @@ import org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints;
import org.jooq.meta.hsqldb.information_schema.tables.Domains;
import org.jooq.meta.hsqldb.information_schema.tables.ElementTypes;
import org.jooq.meta.hsqldb.information_schema.tables.KeyColumnUsage;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
import org.jooq.tools.csv.CSVReader;
import org.jooq.util.h2.H2DataType;
@ -639,6 +635,22 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
.fetch(mapping((s, r) -> new SchemaDefinition(this, s, r)));
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
VIEWS.TABLE_CATALOG,
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME,
VIEWS.VIEW_DEFINITION)
.from(VIEWS)
.where(VIEWS.TABLE_SCHEMA.in(schemas))
.orderBy(
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME)
;
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
Field<Long> minValue = is2_0_202()

View File

@ -77,6 +77,7 @@ import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record6;
import org.jooq.Result;
import org.jooq.ResultQuery;
@ -390,6 +391,22 @@ public class HSQLDBDatabase extends AbstractDatabase implements ResultQueryDatab
.fetch(mapping(s -> new SchemaDefinition(this, s, "")));
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
VIEWS.TABLE_CATALOG,
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME,
VIEWS.VIEW_DEFINITION)
.from(VIEWS)
.where(VIEWS.TABLE_SCHEMA.in(schemas))
.orderBy(
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME)
;
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
return create()

View File

@ -78,6 +78,7 @@ import org.jooq.Field;
// ...
import org.jooq.Record;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record6;
import org.jooq.Result;
import org.jooq.ResultQuery;
@ -424,6 +425,22 @@ public class MySQLDatabase extends AbstractDatabase implements ResultQueryDataba
.collect(mapping(r -> new SchemaDefinition(this, r.value1(), ""), toList()));
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
VIEWS.TABLE_CATALOG,
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME,
VIEWS.VIEW_DEFINITION)
.from(VIEWS)
.where(VIEWS.TABLE_SCHEMA.in(schemas))
.orderBy(
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME)
;
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
return null;

View File

@ -124,6 +124,7 @@ import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record8;
@ -652,6 +653,22 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
.collect(mapping(r -> new SchemaDefinition(this, r.value1(), ""), toList()));
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
VIEWS.TABLE_CATALOG,
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME,
VIEWS.VIEW_DEFINITION)
.from(VIEWS)
.where(VIEWS.TABLE_SCHEMA.in(schemas))
.orderBy(
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME)
;
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
CommonTableExpression<Record1<String>> s = name("schemas").fields("schema").as(selectFrom(values(schemas.stream().collect(toRowArray(DSL::val)))));

View File

@ -56,6 +56,7 @@ import static org.jooq.impl.SQLDataType.VARCHAR;
import static org.jooq.meta.sqlite.sqlite_master.SQLiteMaster.SQLITE_MASTER;
import static org.jooq.tools.StringUtils.isBlank;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
@ -72,7 +73,11 @@ import org.jooq.Meta;
import org.jooq.Query;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record12;
import org.jooq.Record4;
import org.jooq.Record6;
import org.jooq.Result;
import org.jooq.ResultQuery;
import org.jooq.SQLDialect;
import org.jooq.Select;
import org.jooq.SelectConditionStep;
@ -98,6 +103,7 @@ import org.jooq.meta.EnumDefinition;
import org.jooq.meta.IndexColumnDefinition;
import org.jooq.meta.IndexDefinition;
import org.jooq.meta.PackageDefinition;
import org.jooq.meta.ResultQueryDatabase;
import org.jooq.meta.RoutineDefinition;
import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
@ -110,13 +116,14 @@ import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* SQLite implementation of {@link AbstractDatabase}
*
* @author Lukas Eder
*/
public class SQLiteDatabase extends AbstractDatabase {
public class SQLiteDatabase extends AbstractDatabase implements ResultQueryDatabase {
private static final JooqLogger log = JooqLogger.getLogger(SQLiteDatabase.class);
@ -374,6 +381,33 @@ public class SQLiteDatabase extends AbstractDatabase {
return result;
}
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
return create()
.select(
inline(null, VARCHAR).as("catalog"),
inline(null, VARCHAR).as("schema"),
SQLiteMaster.NAME,
SQLiteMaster.SQL)
.from(SQLITE_MASTER)
.orderBy(SQLiteMaster.NAME);
}
@Override
public ResultQuery<Record12<String, String, String, String, Integer, Integer, Long, Long, BigDecimal, BigDecimal, Boolean, Long>> sequences(List<String> schemas) {
return null;
}
@Override
public ResultQuery<Record6<String, String, String, String, String, Integer>> primaryKeys(List<String> schemas) {
return null;
}
@Override
public ResultQuery<Record6<String, String, String, String, String, Integer>> uniqueKeys(List<String> schemas) {
return null;
}
@Override
protected List<TableDefinition> getTables0() throws SQLException {
List<TableDefinition> result = new ArrayList<>();

View File

@ -65,18 +65,16 @@ import static org.jooq.impl.AbstractNamed.findIgnoreCase;
import static org.jooq.impl.DSL.comment;
import static org.jooq.impl.DSL.condition;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.unquotedName;
import static org.jooq.impl.MetaSQL.M_SEQUENCES;
import static org.jooq.impl.MetaSQL.M_SEQUENCES_INCLUDING_SYSTEM_SEQUENCES;
import static org.jooq.impl.MetaSQL.M_SOURCES;
import static org.jooq.impl.MetaSQL.M_UNIQUE_KEYS;
import static org.jooq.impl.SQLDataType.INTEGER;
import static org.jooq.impl.SQLDataType.VARCHAR;
import static org.jooq.impl.Tools.EMPTY_OBJECT;
import static org.jooq.impl.Tools.EMPTY_SORTFIELD;
import static org.jooq.impl.Tools.flatMap;
import static org.jooq.impl.Tools.ignoreNPE;
import static org.jooq.impl.Tools.map;
import static org.jooq.tools.StringUtils.defaultIfEmpty;
import static org.jooq.tools.StringUtils.defaultString;
@ -87,7 +85,6 @@ import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -101,6 +98,7 @@ import org.jooq.Catalog;
import org.jooq.Condition;
import org.jooq.Configuration;
import org.jooq.ConstraintEnforcementStep;
import org.jooq.DSLContext;
import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.ForeignKey;
@ -125,10 +123,8 @@ import org.jooq.exception.DataAccessException;
import org.jooq.exception.DataDefinitionException;
import org.jooq.exception.DataTypeException;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.impl.ThreadGuard.Guard;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
import org.jooq.tools.jdbc.MockResultSet;
/**
* An implementation of the public {@link Meta} type.
@ -342,6 +338,7 @@ final class MetaImpl extends AbstractMeta {
private transient volatile Map<Name, Result<Record>> columnCache;
private transient volatile Map<Name, Result<Record>> ukCache;
private transient volatile Map<Name, Result<Record>> sequenceCache;
private transient volatile Map<Name, String> sourceCache;
MetaSchema(String name, Catalog catalog) {
super(name, catalog);
@ -497,7 +494,7 @@ final class MetaImpl extends AbstractMeta {
}
}
private void initUksSQLite(String catalog, String schema) {
private final void initUksSQLite(String catalog, String schema) {
ukCache = new LinkedHashMap<>();
dsl().resultQuery(
@ -628,7 +625,9 @@ final class MetaImpl extends AbstractMeta {
Map<Record, Result<Record>> groups = result.intoGroups(new Field[] { result.field(0), result.field(1) });
sequenceCache = new LinkedHashMap<>();
groups.forEach((k, v) -> sequenceCache.put(name(k.get(0, String.class), k.get(1, String.class)), v));
groups.forEach((k, v) -> sequenceCache.put(
name(k.get(0, String.class), k.get(1, String.class)), v
));
}
}
@ -637,6 +636,34 @@ final class MetaImpl extends AbstractMeta {
else
return null;
}
final String source(String tableName) {
if (sourceCache == null) {
String sql = M_SOURCES(family());
if (sql != null) {
Result<Record> result = meta(meta -> DSL.using(meta.getConnection(), family()).resultQuery(sql, MetaSchema.this.getName()).fetch());
// TODO Support catalogs as well
Map<Record, Result<Record>> groups = result.intoGroups(new Field[] { result.field(0), result.field(1), result.field(2) });
sourceCache = new LinkedHashMap<>();
groups.forEach((k, v) -> sourceCache.put(
name(k.get(1, String.class), k.get(2, String.class)),
Tools.apply(v.get(0).get(3, String.class), s ->
s.toLowerCase().startsWith("create")
? s
: "create view " + dsl().render(name(k.get(2, String.class))) + " as " + s
)
));
}
}
if (sourceCache != null)
return sourceCache.get(name(MetaSchema.this.getName(), tableName));
else
return null;
}
}
// Columns available from JDBC 3.0+
@ -689,11 +716,22 @@ final class MetaImpl extends AbstractMeta {
String.class // IS_AUTOINCREMENT
};
private static final TableOptions tableOption(DSLContext ctx, MetaSchema schema, String tableName, TableType tableType) {
if (tableType == TableType.VIEW) {
String sql = M_SOURCES(ctx.dialect());
if (sql != null)
return TableOptions.view(schema.source(tableName));
}
return TableOptions.of(tableType);
}
private final class MetaTable extends TableImpl<Record> {
private final Result<Record> uks;
MetaTable(String name, Schema schema, Result<Record> columns, Result<Record> uks, String remarks, TableType tableType) {
super(name(name), schema, null, null, null, null, comment(remarks), TableOptions.of(tableType));
MetaTable(String name, MetaSchema schema, Result<Record> columns, Result<Record> uks, String remarks, TableType tableType) {
super(name(name), schema, null, null, null, null, comment(remarks), tableOption(dsl(), schema, name, tableType));
// Possible scenarios for columns being null:
// - The "table" is in fact a SYNONYM

View File

@ -11,6 +11,7 @@ final class MetaSQL {
private static final EnumMap<SQLDialect, String> M_UNIQUE_KEYS = new EnumMap<>(SQLDialect.class);
private static final EnumMap<SQLDialect, String> M_SEQUENCES = new EnumMap<>(SQLDialect.class);
private static final EnumMap<SQLDialect, String> M_SEQUENCES_INCLUDING_SYSTEM_SEQUENCES = new EnumMap<>(SQLDialect.class);
private static final EnumMap<SQLDialect, String> M_SOURCES = new EnumMap<>(SQLDialect.class);
static final String M_UNIQUE_KEYS(SQLDialect dialect) {
String result = M_UNIQUE_KEYS.get(dialect);
@ -27,6 +28,11 @@ final class MetaSQL {
return result != null ? result : M_SEQUENCES_INCLUDING_SYSTEM_SEQUENCES.get(dialect.family());
}
static final String M_SOURCES(SQLDialect dialect) {
String result = M_SOURCES.get(dialect);
return result != null ? result : M_SOURCES.get(dialect.family());
}
static {
M_UNIQUE_KEYS.put(FIREBIRD, "select null catalog, null schema, trim(RDB$RELATION_CONSTRAINTS.RDB$RELATION_NAME) RDB$RELATION_NAME, trim(RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_NAME) RDB$CONSTRAINT_NAME, trim(RDB$INDEX_SEGMENTS.RDB$FIELD_NAME) RDB$FIELD_NAME, RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION from RDB$RELATION_CONSTRAINTS join RDB$INDEX_SEGMENTS on RDB$INDEX_SEGMENTS.RDB$INDEX_NAME = RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME where RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE = 'UNIQUE' order by RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_NAME asc, RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION asc");
@ -90,6 +96,10 @@ final class MetaSQL {
@ -173,6 +183,87 @@ final class MetaSQL {
M_SOURCES.put(DERBY, "select cast(null as varchar(32672)) as catalog, alias_57844683.SCHEMANAME, SYS.SYSTABLES.TABLENAME, SYS.SYSVIEWS.VIEWDEFINITION from (SYS.SYSTABLES join SYS.SYSSCHEMAS as alias_57844683 on SYS.SYSTABLES.SCHEMAID = alias_57844683.SCHEMAID) left outer join SYS.SYSVIEWS on SYS.SYSTABLES.TABLEID = SYS.SYSVIEWS.TABLEID where cast(alias_57844683.SCHEMANAME as varchar(32672)) in (cast(? as varchar(32672))) order by alias_57844683.SCHEMANAME, SYS.SYSTABLES.TABLENAME");
M_SOURCES.put(FIREBIRD, "select null catalog, null schema, trim(RDB$RELATIONS.RDB$RELATION_NAME), trim(RDB$RELATIONS.RDB$VIEW_SOURCE) from RDB$RELATIONS order by trim(RDB$RELATIONS.RDB$RELATION_NAME)");
M_SOURCES.put(H2, "select INFORMATION_SCHEMA.VIEWS.TABLE_CATALOG, INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA, INFORMATION_SCHEMA.VIEWS.TABLE_NAME, INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION from INFORMATION_SCHEMA.VIEWS where INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA in (cast(? as varchar)) order by INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA, INFORMATION_SCHEMA.VIEWS.TABLE_NAME");
M_SOURCES.put(HSQLDB, "select INFORMATION_SCHEMA.VIEWS.TABLE_CATALOG, INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA, INFORMATION_SCHEMA.VIEWS.TABLE_NAME, INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION from INFORMATION_SCHEMA.VIEWS where INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA in (cast(? as varchar(128))) order by INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA, INFORMATION_SCHEMA.VIEWS.TABLE_NAME");
M_SOURCES.put(MARIADB, "select information_schema.VIEWS.TABLE_CATALOG, information_schema.VIEWS.TABLE_SCHEMA, information_schema.VIEWS.TABLE_NAME, information_schema.VIEWS.VIEW_DEFINITION from information_schema.VIEWS where information_schema.VIEWS.TABLE_SCHEMA in (?) order by information_schema.VIEWS.TABLE_SCHEMA, information_schema.VIEWS.TABLE_NAME");
M_SOURCES.put(MYSQL, "select information_schema.VIEWS.TABLE_CATALOG, information_schema.VIEWS.TABLE_SCHEMA, information_schema.VIEWS.TABLE_NAME, information_schema.VIEWS.VIEW_DEFINITION from information_schema.VIEWS where information_schema.VIEWS.TABLE_SCHEMA in (?) order by information_schema.VIEWS.TABLE_SCHEMA, information_schema.VIEWS.TABLE_NAME");
M_SOURCES.put(POSTGRES, "select information_schema.views.table_catalog, information_schema.views.table_schema, information_schema.views.table_name, information_schema.views.view_definition from information_schema.views where information_schema.views.table_schema in (?) order by information_schema.views.table_schema, information_schema.views.table_name");
M_SOURCES.put(SQLITE, "select null as catalog, null as schema, sqlite_master.name, sqlite_master.sql from sqlite_master order by sqlite_master.name");
M_SOURCES.put(YUGABYTEDB, "select information_schema.views.table_catalog, information_schema.views.table_schema, information_schema.views.table_name, information_schema.views.view_definition from information_schema.views where information_schema.views.table_schema in (?) order by information_schema.views.table_schema, information_schema.views.table_name");