Skip to content

sql: change when txn is checked refresh materialized views#87271

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
e-mbrown:eb/singletxn
Sep 6, 2022
Merged

sql: change when txn is checked refresh materialized views#87271
craig[bot] merged 1 commit intocockroachdb:masterfrom
e-mbrown:eb/singletxn

Conversation

@e-mbrown
Copy link
Copy Markdown
Contributor

@e-mbrown e-mbrown commented Sep 1, 2022

Due to the transaction being checked during planning
and not during execution, refresh materialized views
would fail from the client. Now the transaction is checked
during execution .

Release justification: Bug fix for refresh materialized views

Release note: None

@e-mbrown e-mbrown requested a review from a team September 1, 2022 14:58
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable


if !params.p.extendedEvalCtx.TxnIsSingleStmt {
return pgerror.Newf(pgcode.InvalidTransactionState, "cannot refresh view in a multi-statement transaction")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test in materialized_view_test.go

right below

you can add

	// Verify that refreshing with a prepared statement works.
	preparedStmt, err := sqlDB.Prepare(`REFRESH MATERIALIZED VIEW t.v;`)
	if err != nil {
		t.Fatal(err)
	}
	if _, err := preparedStmt.Exec(); err != nil {
		t.Fatal(err)
	}

Copy link
Copy Markdown
Contributor Author

@e-mbrown e-mbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/refresh_materialized_view.go line 82 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

can you add a test in materialized_view_test.go

right below

you can add

	// Verify that refreshing with a prepared statement works.
	preparedStmt, err := sqlDB.Prepare(`REFRESH MATERIALIZED VIEW t.v;`)
	if err != nil {
		t.Fatal(err)
	}
	if _, err := preparedStmt.Exec(); err != nil {
		t.Fatal(err)
	}

Done.

Copy link
Copy Markdown
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@rafiss
Copy link
Copy Markdown
Collaborator

rafiss commented Sep 1, 2022

let's make sure this gets backported

materialized views

Due to the transaction being checked during planning
and not during execution, refresh materialized views
would fail from the client. Now the transaction is checked
during execution .

Release justification: Bug fix for refresh materialized views

Release note: None
@e-mbrown
Copy link
Copy Markdown
Contributor Author

e-mbrown commented Sep 6, 2022

bors r=rafiss

@craig
Copy link
Copy Markdown
Contributor

craig Bot commented Sep 6, 2022

Build failed (retrying...):

@cockroachdb cockroachdb deleted a comment from craig Bot Sep 6, 2022
@craig
Copy link
Copy Markdown
Contributor

craig Bot commented Sep 6, 2022

Build succeeded:

@craig craig Bot merged commit 825e89e into cockroachdb:master Sep 6, 2022
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Sep 6, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from fcf22cd to blathers/backport-release-22.1-87271: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants