Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented materialized views for pg #120

Merged
merged 6 commits into from Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/SQL/Translator/Parser/PostgreSQL.pm
Expand Up @@ -264,6 +264,19 @@ create : CREATE or_replace(?) temporary(?) VIEW view_id view_fields(?) /AS/i vie
}
}

create: CREATE /MATERIALIZED VIEW/i if_not_exists(?) view_id view_fields(?) /AS/i view_target ';'
{
push @views, {
schema_name => $item{view_id}{schema_name},
view_name => $item{view_id}{view_name},
sql => $item{view_target},
fields => $item[5],
extra => { materialized => 1 }
}
}

if_not_exists : /IF NOT EXISTS/i

trigger_name : NAME

trigger_scope : /FOR/i /EACH/i /(ROW|STATEMENT)/i { $return = lc $1 }
Expand Down
6 changes: 6 additions & 0 deletions t/14postgres-parser.t
Expand Up @@ -113,6 +113,12 @@ baz $foo$,

alter table t_test1 owner to foo;

-- we should tests views if they're supported, right?

create or replace temporary view fez (foo, bar) as select foo, count(bar) as bar from baz group by foo;

create materialized view if not exists baa (black, sheep) as select foo black, bar sheep from baz;

commit;
};

Expand Down