[jOOQ/jOOQ#9483] Add DDLExportConfiguration flags

And also:
[jOOQ/jOOQ#9483] Fixed PG/CRDB meta query, added Db2 implementation
This commit is contained in:
Lukas Eder 2023-09-18 18:13:06 +02:00
parent 5e6ae12455
commit 5853a7e3da
8 changed files with 231 additions and 55 deletions

View File

@ -665,44 +665,24 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
@Override
public ResultQuery<Record4<String, String, String, String>> sources(List<String> schemas) {
Select<Record4<String, String, String, String>> s =
select(
VIEWS.TABLE_CATALOG,
VIEWS.TABLE_SCHEMA,
VIEWS.TABLE_NAME,
when(VIEWS.VIEW_DEFINITION.lower().like(inline("create%")), VIEWS.VIEW_DEFINITION)
.else_(inline("create view \"").concat(VIEWS.TABLE_NAME).concat(inline("\" as ")).concat(VIEWS.VIEW_DEFINITION)).as(VIEWS.VIEW_DEFINITION))
.from(VIEWS);
// [#9483] Some dialects include materialized views in the INFORMATION_SCHEMA.VIEWS view
if (!informationSchemaViewsContainsMaterializedViews()) {
s = s.unionAll(
select(
currentCatalog(),
PG_CLASS.pgNamespace().NSPNAME,
PG_CLASS.RELNAME,
inline("create materialized view \"").concat(PG_CLASS.RELNAME).concat(inline("\" as ")).concat(field("pg_get_viewdef({0})", VARCHAR, PG_CLASS.OID)))
.from(PG_CLASS)
.where(PG_CLASS.RELKIND.eq(inline("m")))
);
}
Table<?> t = s.asTable("t");
PgClass c = PG_CLASS.as("c");
return create()
.select(
t.field(VIEWS.TABLE_CATALOG),
t.field(VIEWS.TABLE_SCHEMA),
t.field(VIEWS.TABLE_NAME),
t.field(VIEWS.VIEW_DEFINITION))
.from(t)
.where(t.field(VIEWS.TABLE_SCHEMA).in(schemas))
.orderBy(1, 2, 3)
;
}
protected boolean informationSchemaViewsContainsMaterializedViews() {
return false;
currentCatalog(),
c.pgNamespace().NSPNAME,
c.RELNAME,
when(c.RELKIND.eq(inline("m")), inline("create materialized view \""))
.else_(inline("create view \""))
.concat(c.RELNAME)
.concat(inline("\" as "))
.concat(field("pg_get_viewdef({0})", VARCHAR, c.OID)))
.from(c)
.where(c.RELKIND.in(inline("v"), inline("m")))
.and(c.pgNamespace().NSPNAME.in(schemas))
.orderBy(1, 2, 3);
}
@Override

View File

@ -58,7 +58,9 @@ public final class DDLExportConfiguration {
private final boolean createDomainIfNotExists;
private final boolean createSequenceIfNotExists;
private final boolean createViewIfNotExists;
private final boolean createMaterializedViewIfNotExists;
private final boolean createOrReplaceView;
private final boolean createOrReplaceMaterializedView;
private final boolean respectCatalogOrder;
private final boolean respectSchemaOrder;
@ -87,6 +89,8 @@ public final class DDLExportConfiguration {
false,
false,
false,
false,
false,
false,
false,
@ -112,7 +116,9 @@ public final class DDLExportConfiguration {
boolean createDomainIfNotExists,
boolean createSequenceIfNotExists,
boolean createViewIfNotExists,
boolean createMaterializedViewIfNotExists,
boolean createOrReplaceView,
boolean createOrReplaceMaterializedView,
boolean respectCatalogOrder,
boolean respectSchemaOrder,
@ -135,7 +141,9 @@ public final class DDLExportConfiguration {
this.createDomainIfNotExists = createDomainIfNotExists;
this.createSequenceIfNotExists = createSequenceIfNotExists;
this.createViewIfNotExists = createViewIfNotExists;
this.createMaterializedViewIfNotExists = createMaterializedViewIfNotExists;
this.createOrReplaceView = createOrReplaceView;
this.createOrReplaceMaterializedView = createOrReplaceMaterializedView;
this.respectCatalogOrder = respectCatalogOrder;
this.respectSchemaOrder = respectSchemaOrder;
@ -177,7 +185,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -214,7 +224,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -251,7 +263,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -288,7 +302,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -325,7 +341,9 @@ public final class DDLExportConfiguration {
newCreateDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -362,7 +380,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
newCreateSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -399,7 +419,48 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
newCreateViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
respectColumnOrder,
respectConstraintOrder,
respectIndexOrder,
respectDomainOrder,
respectSequenceOrder,
defaultSequenceFlags,
includeConstraintsOnViews
);
}
/**
* Whether to generate <code>CREATE MATERIALIZED VIEW IF NOT EXISTS</code> statements.
* <p>
* Not all RDBMS support this flag. Check
* {@link DSLContext#createMaterializedViewIfNotExists(Table, Field...)} to see if your
* {@link SQLDialect} supports the clause.
*/
public final boolean createMaterializedViewIfNotExists() {
return createMaterializedViewIfNotExists;
}
/**
* Whether to generate <code>CREATE MATERIALIZED VIEW IF NOT EXISTS</code> statements.
*/
public final DDLExportConfiguration createMaterializedViewIfNotExists(boolean newCreateMaterializedViewIfNotExists) {
return new DDLExportConfiguration(
flags,
createSchemaIfNotExists,
createTableIfNotExists,
createIndexIfNotExists,
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
newCreateMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -436,7 +497,48 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
newCreateOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
respectColumnOrder,
respectConstraintOrder,
respectIndexOrder,
respectDomainOrder,
respectSequenceOrder,
defaultSequenceFlags,
includeConstraintsOnViews
);
}
/**
* Whether to generate <code>CREATE OR REPLACE MATERIALIZED VIEW</code> statements.
* <p>
* Not all RDBMS support this flag. Check
* {@link DSLContext#createOrReplaceMaterializedView(Table, Field...)} to see if your
* {@link SQLDialect} supports the clause.
*/
public final boolean createOrReplaceMaterializedView() {
return createOrReplaceMaterializedView;
}
/**
* Whether to generate <code>CREATE OR REPLACE MATERIALIZED VIEW</code> statements.
*/
public final DDLExportConfiguration createOrReplaceMaterializedView(boolean newCreateOrReplaceMaterializedView) {
return new DDLExportConfiguration(
flags,
createSchemaIfNotExists,
createTableIfNotExists,
createIndexIfNotExists,
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
newCreateOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -471,7 +573,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
newRespectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -506,7 +610,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
newRespectSchemaOrder,
respectTableOrder,
@ -541,7 +647,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
newRespectTableOrder,
@ -576,7 +684,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -611,7 +721,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -646,7 +758,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -681,7 +795,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -716,7 +832,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -751,7 +869,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,
@ -784,7 +904,9 @@ public final class DDLExportConfiguration {
createDomainIfNotExists,
createSequenceIfNotExists,
createViewIfNotExists,
createMaterializedViewIfNotExists,
createOrReplaceView,
createOrReplaceMaterializedView,
respectCatalogOrder,
respectSchemaOrder,
respectTableOrder,

View File

@ -155,9 +155,10 @@ implements
private static final Clause[] CLAUSES = { Clause.CREATE_VIEW };
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedUntil(DERBY, FIREBIRD, MYSQL, POSTGRES, YUGABYTEDB);
private static final Set<SQLDialect> NO_SUPPORT_COLUMN_RENAME = SQLDialect.supportedBy(TRINO);
private static final Clause[] CLAUSES = { Clause.CREATE_VIEW };
private static final Set<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = SQLDialect.supportedUntil(DERBY, FIREBIRD, MYSQL, POSTGRES, YUGABYTEDB);
private static final Set<SQLDialect> NO_SUPPORT_COLUMN_RENAME = SQLDialect.supportedBy(TRINO);
private static final Set<SQLDialect> NO_SUPPORT_COLUMN_RENAME_MVIEW = SQLDialect.supportedBy(H2);
private transient Select<?> parsed;
private final boolean supportsIfNotExists(Context<?> ctx) {
@ -173,11 +174,65 @@ implements
}
private final void accept0(Context<?> ctx) {
switch (ctx.family()) {
default:
acceptDefault(ctx);
break;
}
}
private final void acceptDefault(Context<?> ctx) {
List<? extends Field<?>> f = fields;
// [#2059] [#11485] Some dialects don't support column aliases at the view level
boolean rename = f != null && f.size() > 0;
boolean renameSupported = !NO_SUPPORT_COLUMN_RENAME.contains(ctx.dialect());
boolean renameSupported =
materialized && !NO_SUPPORT_COLUMN_RENAME_MVIEW.contains(ctx.dialect())
|| !materialized && !NO_SUPPORT_COLUMN_RENAME.contains(ctx.dialect());
boolean replaceSupported = false ;

View File

@ -138,17 +138,17 @@ final class DDL {
result.add(
applyAs(
configuration.createViewIfNotExists()
? materialized
materialized
? configuration.createMaterializedViewIfNotExists()
? ctx.createMaterializedViewIfNotExists(table, table.fields())
: ctx.createViewIfNotExists(table, table.fields())
: configuration.createOrReplaceView()
? materialized
: configuration.createOrReplaceMaterializedView()
? ctx.createOrReplaceMaterializedView(table, table.fields())
: ctx.createOrReplaceView(table, table.fields())
: materialized
? ctx.createMaterializedView(table, table.fields())
: ctx.createView(table, table.fields()),
: ctx.createMaterializedView(table, table.fields())
: configuration.createViewIfNotExists()
? ctx.createViewIfNotExists(table, table.fields())
: configuration.createOrReplaceView()
? ctx.createOrReplaceView(table, table.fields())
: ctx.createView(table, table.fields()),
table.getOptions()
)
);

View File

@ -115,10 +115,25 @@ implements
ctx.start(Clause.DROP_VIEW_TABLE)
.visit(K_DROP).sql(' ');
if (materialized)
ctx.visit(K_MATERIALIZED).sql(' ');
if (materialized) {
switch (ctx.family()) {
ctx.visit(K_VIEW).sql(' ');
default:
ctx.visit(K_MATERIALIZED).sql(' ').visit(K_VIEW).sql(' ');
break;
}
}
else
ctx.visit(K_VIEW).sql(' ');
if (ifExists && supportsIfExists(ctx))
ctx.visit(K_IF_EXISTS).sql(' ');

View File

@ -130,6 +130,7 @@ final class Keywords {
static final Keyword K_DECLARE = keyword("declare");
static final Keyword K_DEFAULT = keyword("default");
static final Keyword K_DEFAULT_VALUES = keyword("default values");
static final Keyword K_DEFERRED = keyword("deferred");
static final Keyword K_DEFINE = keyword("define");
static final Keyword K_DELETE = keyword("delete");
static final Keyword K_DENSE_RANK = keyword("dense_rank");
@ -218,6 +219,7 @@ final class Keywords {
static final Keyword K_INCLUDE_NULL_VALUES = keyword("include_null_values");
static final Keyword K_INCREMENT_BY = keyword("increment by");
static final Keyword K_INDEX = keyword("index");
static final Keyword K_INITIALLY = keyword("initially");
static final Keyword K_INLINE = keyword("inline");
static final Keyword K_INOUT = keyword("inout");
static final Keyword K_INSERT = keyword("insert");
@ -340,6 +342,7 @@ final class Keywords {
static final Keyword K_REF = keyword("ref");
static final Keyword K_REFERENCES = keyword("references");
static final Keyword K_REFERENCING = keyword("referencing");
static final Keyword K_REFRESH = keyword("refresh");
static final Keyword K_REGEXP = keyword("regexp");
static final Keyword K_RELEASE = keyword("release");
static final Keyword K_REMOVE = keyword("remove");

View File

@ -690,7 +690,7 @@ final class MetaImpl extends AbstractMeta {
return null;
}
final String source(String tableName) {
final String source(TableType type, String tableName) {
if (sourceCache == null) {
String sql = M_SOURCES(family());
@ -710,7 +710,8 @@ final class MetaImpl extends AbstractMeta {
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
: (type == MATERIALIZED_VIEW ? "create materialized view " : "create view ")
+ dsl().render(name(k.get(2, String.class))) + " as " + s
)
));
}
@ -820,9 +821,9 @@ final class MetaImpl extends AbstractMeta {
if (sql != null)
if (tableType == MATERIALIZED_VIEW)
return TableOptions.materializedView(schema.source(tableName));
return TableOptions.materializedView(schema.source(tableType, tableName));
else
return TableOptions.view(schema.source(tableName));
return TableOptions.view(schema.source(tableType, tableName));
}
return TableOptions.of(tableType);

View File

@ -260,10 +260,10 @@ final class MetaSQL {
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, case when lower(information_schema.VIEWS.VIEW_DEFINITION) like 'create%' then information_schema.VIEWS.VIEW_DEFINITION else concat(concat(concat('create view `', information_schema.VIEWS.TABLE_NAME), '` as '), information_schema.VIEWS.VIEW_DEFINITION) end as 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, case when lower(information_schema.VIEWS.VIEW_DEFINITION) like 'create%' then information_schema.VIEWS.VIEW_DEFINITION else concat(concat(concat('create view `', information_schema.VIEWS.TABLE_NAME), '` as '), information_schema.VIEWS.VIEW_DEFINITION) end as 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 t.table_catalog, t.table_schema, t.table_name, t.view_definition from (select information_schema.views.table_catalog, information_schema.views.table_schema, information_schema.views.table_name, case when lower(information_schema.views.view_definition) like 'create%' then information_schema.views.view_definition else ((('create view \"' || information_schema.views.table_name) || '\" as ') || information_schema.views.view_definition) end as view_definition from information_schema.views union all select current_database(), alias_87241969.nspname, pg_catalog.pg_class.relname, ((('create materialized view \"' || pg_catalog.pg_class.relname) || '\" as ') || pg_get_viewdef(pg_catalog.pg_class.oid)) from (pg_catalog.pg_class join pg_catalog.pg_namespace as alias_87241969 on pg_catalog.pg_class.relnamespace = alias_87241969.oid) where pg_catalog.pg_class.relkind = 'm') as t where t.table_schema in (?) order by 1, 2, 3");
M_SOURCES.put(POSTGRES, "select current_database(), alias_87241969.nspname, pg_catalog.pg_class.relname, (((case when pg_catalog.pg_class.relkind = 'm' then 'create materialized view \"' else 'create view \"' end || pg_catalog.pg_class.relname) || '\" as ') || pg_get_viewdef(pg_catalog.pg_class.oid)) from (pg_catalog.pg_class join pg_catalog.pg_namespace as alias_87241969 on pg_catalog.pg_class.relnamespace = alias_87241969.oid) where (pg_catalog.pg_class.relkind in ('v', 'm') and alias_87241969.nspname in (?)) order by 1, 2, 3");
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(TRINO, "select '' TABLE_CATALOG, INFORMATION_SCHEMA.VIEWS.TABLE_SCHEMA, INFORMATION_SCHEMA.VIEWS.TABLE_NAME, case when lower(INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION) like 'create%' then INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION else ((('create view \"' || INFORMATION_SCHEMA.VIEWS.TABLE_NAME) || '\" as ') || INFORMATION_SCHEMA.VIEWS.VIEW_DEFINITION) end 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(YUGABYTEDB, "select t.table_catalog, t.table_schema, t.table_name, t.view_definition from (select information_schema.views.table_catalog, information_schema.views.table_schema, information_schema.views.table_name, case when lower(information_schema.views.view_definition) like 'create%' then information_schema.views.view_definition else ((('create view \"' || information_schema.views.table_name) || '\" as ') || information_schema.views.view_definition) end as view_definition from information_schema.views union all select current_database(), alias_87241969.nspname, pg_catalog.pg_class.relname, ((('create materialized view \"' || pg_catalog.pg_class.relname) || '\" as ') || pg_get_viewdef(pg_catalog.pg_class.oid)) from (pg_catalog.pg_class join pg_catalog.pg_namespace as alias_87241969 on pg_catalog.pg_class.relnamespace = alias_87241969.oid) where pg_catalog.pg_class.relkind = 'm') as t where t.table_schema in (?) order by 1, 2, 3");
M_SOURCES.put(YUGABYTEDB, "select current_database(), alias_87241969.nspname, pg_catalog.pg_class.relname, (((case when pg_catalog.pg_class.relkind = 'm' then 'create materialized view \"' else 'create view \"' end || pg_catalog.pg_class.relname) || '\" as ') || pg_get_viewdef(pg_catalog.pg_class.oid)) from (pg_catalog.pg_class join pg_catalog.pg_namespace as alias_87241969 on pg_catalog.pg_class.relnamespace = alias_87241969.oid) where (pg_catalog.pg_class.relkind in ('v', 'm') and alias_87241969.nspname in (?)) order by 1, 2, 3");