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: allow CREATE UNLOGGED TABLE syntax #52596

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

otan
Copy link
Contributor

@otan otan commented Aug 10, 2020

In SQL, a CREATE TABLE can take in TEMP | UNLOGGED. Accordingly, I've
updated the sql.y to account for this, changing the opt_temp from a bool
to a tree.Persistence ENUM that can be PERMANENT, TEMPORARY or
UNLOGGED. This introduced some downstream changes to various package to
recognize these arguments. Note sequences and views cannot be unlogged.
This makes up the majority of the changes.

Otherwise, recognize UNLOGGED TABLE in teh parser. Add a warning that the
use of UNLOGGED TABLE does not actually do anything.
Note this is always safe as UNLOGGED TABLE is a performance improvement
in PostgreSQL by sacrificing crash-safety. In our case, we'll still always
have safety features and thus still be correct, albeit slower.

Release note (sql change): Allow CREATE UNLOGGED TABLE syntax to be
parsed and recorded internally within CockroachDB. However, this syntax
does not modify behavior of the table.

Resolves #43352.
Refs #51818

@otan otan requested a review from a team August 10, 2020 20:24
@otan otan requested a review from a team as a code owner August 10, 2020 20:24
@otan otan requested review from dt and removed request for a team August 10, 2020 20:24
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan requested review from arulajmani and a team August 10, 2020 20:25
@otan otan force-pushed the unlogged_table branch 4 times, most recently from 18e7bf4 to d57c5c1 Compare August 10, 2020 23:03
@rohany
Copy link
Contributor

rohany commented Aug 11, 2020

If it does nothing, why are you storing it on the table descriptor?

@dt dt removed their request for review August 11, 2020 00:18
@otan
Copy link
Contributor Author

otan commented Aug 11, 2020

I don't know where to stop!

I may have to implement SET UNLOGGED and SET LOGGED and it needs that to be set to behave correctly, hehe.

@rohany
Copy link
Contributor

rohany commented Aug 11, 2020

I don't think we should be writing this information to disk if it is to be used just to play with these commands. Why can't we just parse and noop the related commands?

@otan
Copy link
Contributor Author

otan commented Aug 11, 2020

i honestly could be swayed either way.

i don't want a no-op and "parse through" in the sql.y layer as i do want an explicit warning/notice, which you cannot do from the sql.y bit.

@rohany
Copy link
Contributor

rohany commented Aug 11, 2020

I agree that you'll have to implement some plan nodes, but I'd prefer for those to be noops than having to do something to the table

@otan
Copy link
Contributor Author

otan commented Aug 11, 2020

alright well, change made :P

@@ -73,6 +73,9 @@ func ShowCreateTable(

f := tree.NewFmtCtx(tree.FmtSimple)
f.WriteString("CREATE ")
if desc.Unlogged {
f.WriteString("UNLOGGED ")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @rohany. If the UNLOGGED keyword does nothing, I think it's misleading to label the table as UNLOGGED in SHOW CREATE. If you remove this, I think you can avoid storing anything new in a descriptor, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought i removed this on cleanup!

In SQL, a CREATE TABLE can take in TEMP | UNLOGGED. Accordingly, I've
updated the sql.y to account for this, changing the opt_temp from a bool
to a `tree.Persistence` ENUM that can be PERMANENT, TEMPORARY or
UNLOGGED. This introduced some downstream changes to various package to
recognize these arguments. Note sequences and views cannot be unlogged.
This makes up the majority of the changes.

Otherwise, recognize UNLOGGED TABLE in teh parser. Add a warning that the
use of UNLOGGED TABLE does not actually do anything.
Note this is always safe as UNLOGGED TABLE is a performance improvement
in PostgreSQL by sacrificing crash-safety. In our case, we'll still always
have safety features and thus still be correct, albeit slower.

Release note (sql change): Allow `CREATE UNLOGGED TABLE` syntax to be
parsed and recorded internally within CockroachDB. However, this syntax
does not modify behavior of the table.
@otan
Copy link
Contributor Author

otan commented Aug 11, 2020

thankssss

bors r=rohany

@otan
Copy link
Contributor Author

otan commented Aug 11, 2020

bors bors the magical fruit
the more you eat the more you toot
(didn't seem to want to process my PR)

bors r=rohany

@dt
Copy link
Member

dt commented Aug 11, 2020

bors? flaky? unheard of.

@craig
Copy link
Contributor

craig bot commented Aug 11, 2020

Build succeeded:

@craig craig bot merged commit 622bb5c into cockroachdb:master Aug 11, 2020
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.

sql: support unlogged table
5 participants