Skip to content

sql: fix a bunch of minor spacing issues in the grammar#25216

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
BramGruneir:spacinmg
May 15, 2018
Merged

sql: fix a bunch of minor spacing issues in the grammar#25216
craig[bot] merged 1 commit intocockroachdb:masterfrom
BramGruneir:spacinmg

Conversation

@BramGruneir
Copy link
Copy Markdown
Member

I was trying to do some searching and couldn't find what I was looking for due
to inconsistent spacing.

We should move towards adding a linter for the grammer.

Release note: None

@BramGruneir BramGruneir added this to the 2.1 milestone May 1, 2018
@BramGruneir BramGruneir requested review from a team and knz May 1, 2018 18:52
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz
Copy link
Copy Markdown
Contributor

knz commented May 1, 2018

How did you do this change? Did you automate it? How?

@BramGruneir
Copy link
Copy Markdown
Member Author

If I automated it I would have included the steps.

Finding the double, triple, quadruple spaces was easy. Just a search for and multi-line edit to fix them.

The rest was looking for : and see if things didn't line up. So that was more manually, but I needed a break from other work and just did it on autopilot while enjoying some music. Didn't take very long.

Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

This patch is a mixed bag of desirable stuff (the alignment of %type directives) and less desirable stuff. I wish we could break this up in multiple parts so we can discuss them separately.

I am also a little bit concerned that any subsequent patches on the 2.0 branch will get merge conflicts.


// Note: newlines between non-terminals matter to the doc generator.

collation_name: unrestricted_name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one-line change and those below don't seem justified - there's nothing to align wish, so why the different amount of spacing?


%token <str> ZONE
%token <str> ZONE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All the changes above this point are not justified -- the code was homogeneous, there was no irregularity.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's not entirely true.

%token <*tree.NumVal> ICONST FCONST uses only one space already.

I just don't know of any instance in which we use a double spaces for

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok let's keep your change here.

%token NOT_LA WITH_LA AS_LA

%union {
id int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this struct change does not appear justiifed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This one was weird. I don't understand the huge spacing. I can revert it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's keep it your way.

{
$$.val = &tree.AlterTableDropColumn{
ColumnKeyword: $2.bool(),
IfExists: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

from here on to my next comment, I see where you're coming from but I'm not sure the change is properly justified. I would even argue we're making a step back: because we don't have gofmt support for goyacc files (nor editor support to auto-align struct initializers), requiring extra spaces is actually extra work (now people have to manually align things with their space bar).

What do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

More than half of these were already aligned as if it were using gofmt. So that's why I made the change. We should have a consistent style and we don't. I opted for the style that matches the rest of our codebase.

Manually adding the spaces ins't a big deal but without linter support, it will not be enforceable.

There IS yacc file support in a lot of editors, but our specific blend of go and the grammar broke every one that I tried.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More than half of these were already aligned as if it were using gofmt.

I don't see that's true. Can you show me?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just went back through and did a bit of an audit of them. Most were not formatted. But there is a mix.

Take a look at the $$.val = &tree.CreateIndex{ Of the 4, 2 were formatted, 1 was not, and 1 was half formatted.

I'd still rather we format them in gofmt style to match the rest of our codebase. But I'll leave the final decision up to you. I find it more readable and I don't think the manual alignment is hard to do or enforce. But the most important thing here is to be consistent. So let me know either way.

Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

I am coming to like most of the changes. I still have reservations about the struct initializations. Please provide more information (see comment below).


%token <str> ZONE
%token <str> ZONE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok let's keep your change here.

%token NOT_LA WITH_LA AS_LA

%union {
id int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's keep it your way.

{
$$.val = &tree.AlterTableDropColumn{
ColumnKeyword: $2.bool(),
IfExists: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More than half of these were already aligned as if it were using gofmt.

I don't see that's true. Can you show me?

@knz
Copy link
Copy Markdown
Contributor

knz commented May 14, 2018

Let's skip the struct alignment for now unless you also can implement a linter for it straight away. I don't see anyone in the team willing (or able) to properly check this manually during future reviews.

The rest LGTM


Reviewed 1 of 1 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

I was trying to do some searching and couldn't find what I was looking for due
to inconsistent spacing.

We should move towards adding a linter for the grammer.

Release note: None
@BramGruneir
Copy link
Copy Markdown
Member Author

Done. I've created a branch with just the spacing changes for for the struct alignment, so we don't have to start from scratch if we do move in that direction.

https://github.com/BramGruneir/cockroach/tree/spacing2


Review status: 0 of 1 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@BramGruneir
Copy link
Copy Markdown
Member Author

bors r+

@knz
Copy link
Copy Markdown
Contributor

knz commented May 15, 2018

Thanks!

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 15, 2018

Merge conflict (retrying...)

@BramGruneir
Copy link
Copy Markdown
Member Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 15, 2018

Merge conflict (retrying...)

@BramGruneir
Copy link
Copy Markdown
Member Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 15, 2018

Build failed (retrying...)

@BramGruneir
Copy link
Copy Markdown
Member Author

BramGruneir commented May 15, 2018 via email

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 15, 2018

Not awaiting review

craig bot pushed a commit that referenced this pull request May 15, 2018
25216: sql: fix a bunch of minor spacing issues in the grammar r=BramGruneir a=BramGruneir

I was trying to do some searching and couldn't find what I was looking for due
to inconsistent spacing.

We should move towards adding a linter for the grammer.

Release note: None

25322: storage: proactively renew r1's lease r=a-robinson a=a-robinson

This mechanism won't scale incredibly well to proactively renewing all
expiration-based leases since it'd require a goroutine per lease. It
should be fine if we only auto-renew r1's lease, though.

Fixes #24753

Release note: None

----------------

@bdarnell, do you have any suggestions for testing this? I've verified it manually, but it's hard to properly isolate this code in a realistic way. We could ratchet the lease durations way down and wait until the lease's expiration bumps, but that creates a timing-based test that is either flaky if we use a really short lease duration or slow if we use a long one.

Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 15, 2018

Build succeeded

@craig craig bot merged commit 59b81c7 into cockroachdb:master May 15, 2018
@BramGruneir BramGruneir deleted the spacinmg branch May 16, 2018 17:26
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