Skip to content

sql: refresh materialized views in explicit transactions #66008

@awoods187

Description

@awoods187

Currently, we can’t refresh a materialized view inside an explicit transaction:

demo@127.0.0.1:26257/movr  OPEN> REFRESH MATERIALIZED VIEW overdrawn_accounts;
ERROR: cannot refresh view in an explicit transaction
SQLSTATE: 25000

Refresh is an asynchronous job which can be difficult for use to handle inside a transaction.

This is problematic because many users leverage ORMs who often wrap all SQL inside explicit transactions. As a result, a developer could create a materialized view but not be able to refresh it, rendering it unusable. We should support transactional refreshes both for this use case and because developers may want to leverage the results of a refreshed view later on within an explicit transaction.

Jira issue: CRDB-7833

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions