Materialized views #123

This commit is contained in:
Jan Prochazka
2021-05-30 10:13:38 +02:00
parent 93edcc4d0a
commit 35fc2e0f5b
6 changed files with 46 additions and 10 deletions

View File

@@ -293,6 +293,20 @@ export class SqlDumper {
changeViewSchema(obj: ViewInfo, newSchema: string) {}
renameView(obj: ViewInfo, newSchema: string) {}
createMatview(obj: ViewInfo) {
this.putRaw(obj.createSql);
this.endCommand();
}
dropMatview(obj: ViewInfo, { testIfExists = false }) {
this.putCmd('^drop ^materialized ^view %f', obj);
}
alterMatview(obj: ViewInfo) {
this.putRaw(obj.createSql.replace(/create\s+view/i, 'ALTER VIEW'));
this.endCommand();
}
changeMatviewSchema(obj: ViewInfo, newSchema: string) {}
renameMatview(obj: ViewInfo, newSchema: string) {}
createProcedure(obj: ProcedureInfo) {
this.putRaw(obj.createSql);
this.endCommand();

View File

@@ -30,6 +30,10 @@ interface SqlGeneratorOptions {
checkIfViewExists: boolean;
createViews: boolean;
dropMatviews: boolean;
checkIfMatviewExists: boolean;
createMatviews: boolean;
dropProcedures: boolean;
checkIfProcedureExists: boolean;
createProcedures: boolean;
@@ -52,6 +56,7 @@ interface SqlGeneratorObject {
export class SqlGenerator {
private tables: TableInfo[];
private views: ViewInfo[];
private matviews: ViewInfo[];
private procedures: ProcedureInfo[];
private functions: FunctionInfo[];
private triggers: TriggerInfo[];
@@ -70,6 +75,7 @@ export class SqlGenerator {
this.dbinfo = extendDatabaseInfo(dbinfo);
this.tables = this.extract('tables');
this.views = this.extract('views');
this.matviews = this.extract('matviews');
this.procedures = this.extract('procedures');
this.functions = this.extract('functions');
this.triggers = this.extract('triggers');
@@ -90,6 +96,8 @@ export class SqlGenerator {
if (this.checkDumper()) return;
this.dropObjects(this.views, 'View');
if (this.checkDumper()) return;
this.dropObjects(this.matviews, 'Matview');
if (this.checkDumper()) return;
this.dropObjects(this.triggers, 'Trigger');
if (this.checkDumper()) return;
@@ -114,6 +122,8 @@ export class SqlGenerator {
if (this.checkDumper()) return;
this.createObjects(this.views, 'View');
if (this.checkDumper()) return;
this.createObjects(this.matviews, 'Matview');
if (this.checkDumper()) return;
this.createObjects(this.triggers, 'Trigger');
if (this.checkDumper()) return;
} finally {