Skip to content

opt: fix panic caused by select from table with no columns#28589

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-panic
Aug 15, 2018
Merged

opt: fix panic caused by select from table with no columns#28589
craig[bot] merged 1 commit intocockroachdb:masterfrom
rytaft:fix-panic

Conversation

@rytaft
Copy link
Copy Markdown
Collaborator

@rytaft rytaft commented Aug 14, 2018

This commit fixes a panic caused by running SELECT * from a table
with no visible columns (e.g., a table with only the hidden rowid
column). The bug was caused by the optbuilder creating a Presentation
slice even when there are no columns to present. Ensuring that
the slice is nil in this case fixes the bug.

Fixes #28388

Release note: None

This commit fixes a panic caused by running `SELECT *` from a table
with no visible columns (e.g., a table with only the hidden rowid
column). The bug was caused by the optbuilder creating a Presentation
slice even when there are no columns to present. Ensuring that
the slice is nil in this case fixes the bug.

Fixes cockroachdb#28388

Release note: None
@rytaft rytaft requested a review from a team as a code owner August 14, 2018 20:49
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown

@madhavsuresh madhavsuresh left a comment

Choose a reason for hiding this comment

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

:lgtm: would it make sense to add a logictest for this? Ensure that the result is empty?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

Copy link
Copy Markdown
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

TFTR!

would it make sense to add a logictest for this? Ensure that the result is empty?

That's a good idea, but I don't think it's possible to test this with the logictest framework. As far as I can tell, the typestring is required (e.g., query III, indicating 3 integer columns), so there's no way to indicate 0 columns (@RaduBerinde, please correct me if I'm wrong). I think this existing test is probably good enough:

.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

Copy link
Copy Markdown

@madhavsuresh madhavsuresh left a comment

Choose a reason for hiding this comment

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

sgtm!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Yeah, I don't know how to write a logictest like that. This seems good enough. :lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale)

Copy link
Copy Markdown
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Thanks!

bors r+

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained

craig bot pushed a commit that referenced this pull request Aug 15, 2018
24194: RFC: parallel commits r=tschottdorf a=tschottdorf

The parallel commits tech note describes a proposal for reducing commit
latencies. It comes in a basic and extended flavor, the latter of which
requiring more engineering work. I believe we should pursue the former
sooner rather than later, and make the latter contingent on the fate of
the required second tech note, which suggests a new format for
transaction IDs and explores some of the expected benefits.

Release note: None

28589: opt: fix panic caused by select from table with no columns r=rytaft a=rytaft

This commit fixes a panic caused by running `SELECT *` from a table
with no visible columns (e.g., a table with only the hidden rowid
column). The bug was caused by the `optbuilder` creating a `Presentation`
slice even when there are no columns to present. Ensuring that
the slice is nil in this case fixes the bug.

Fixes #28388

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 15, 2018

Build succeeded

@craig craig bot merged commit 7d6e4a5 into cockroachdb:master Aug 15, 2018
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.

opt: select on empty table with no columns causes panic

4 participants