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

sql: fix "descriptor not found" error when dropping a database with t… #67104

Conversation

ajwerner
Copy link
Contributor

@ajwerner ajwerner commented Jul 1, 2021

…emp views

The bug here is that there are cases in drop database cascade where we'll
attempt to qualify the name of a view involved in a cascaded drop that is
not part of the current session's temporary schema. In that scenario, we
don't know the schema except by its ID. The temporary schemas do not have
descriptors, only namespace entries.

We could do something different like delete all of the views first but that
won't help for the backport PR we need to make as we only carry prefix
descriptors around in master.

Release note (bug fix): Fixed a bug where DROP DATABASE could return errors
if the database contained temporary views in use in an another session.

@ajwerner ajwerner requested a review from mgartner July 1, 2021 05:02
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the ajwerner/fix-weird-error-when-dropping-a-database branch 2 times, most recently from 81cdf61 to 3e5d774 Compare July 1, 2021 17:25
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! :lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)


pkg/sql/logictest/testdata/logic_test/temp_table, line 305 at r1 (raw file):

CREATE TABLE not_temp (i INT PRIMARY KEY);
CREATE TEMPORARY TABLE "testuser_tmp" (i INT PRIMARY KEY);
CREATE TEMPORARY VIEW "tempuser_view" AS SELECT i FROM testuser_tmp;

nit: is there a need for the "s?


pkg/sql/logictest/testdata/logic_test/temp_table, line 327 at r1 (raw file):

			),
			'pg_temp_[^.]+.',
			'pg_temp.'

nit: replace tabs with spaces and align SELECT

…emp views

The bug here is that there are cases in drop database cascade where we'll
attempt to qualify the name of a view involved in a cascaded drop that is
not part of the current session's temporary schema. In that scenario, we
don't know the schema except by its ID. The temporary schemas do not have
descriptors, only namespace entries.

We could do something different like delete all of the views first but that
won't help for the backport PR we need to make as we only carry prefix
descriptors around in master.

Release note (bug fix): Fixed a bug where DROP DATABASE could return errors
if the database contained temporary views in use in an another session.
@ajwerner ajwerner force-pushed the ajwerner/fix-weird-error-when-dropping-a-database branch from 3e5d774 to eb92821 Compare July 1, 2021 21:34
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner)

@ajwerner
Copy link
Contributor Author

ajwerner commented Jul 1, 2021

TFTR

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 2, 2021

Build succeeded:

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