Skip to content

sql: remove last 2 blockers for pgcli support#40949

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
jordanlewis:pgcli
Sep 25, 2019
Merged

sql: remove last 2 blockers for pgcli support#40949
craig[bot] merged 2 commits intocockroachdb:masterfrom
jordanlewis:pgcli

Conversation

@jordanlewis
Copy link
Copy Markdown
Member

sql: add syntax for arrays of oid wrapper types

Previously, syntax for the special oid wrapper types (like REGCLASS,
REGTYPE, and so on) was not available, despite the backend being able to
handle these types just fine.

This commit adds syntax for this (e.g. `select t::regclass[]`) to the
parser and hooks it up to the type system.
tree: add support for REGTYPE casts of the trigger type

Release note (sql change): support the syntax for oid wrapper arrays, like REGCLASS[], and REGTYPE casts for the unsupported trigger type.
Release justification: low risk, cosmetic compatibility improvement.

Previously, syntax for the special oid wrapper types (like REGCLASS,
REGTYPE, and so on) was not available, despite the backend being able to
handle these types just fine.

This commit adds syntax for this (e.g. `select t::regclass[]`) to the
parser and hooks it up to the type system.

Release note (sql change): support the syntax for oid wrapper arrays,
like REGCLASS[].
Release justification: low risk, cosmetic compatibility improvement.
Release note: None
Release justification: low-risk, cosmetic compatibility improvement
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@jordanlewis jordanlewis requested a review from rafiss September 23, 2019 20:45
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! i understood everything except for one of the parts you removed

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis, @RaduBerinde, @rafiss, and @spaskob)


pkg/sql/parser/sql.y, line 6756 at r1 (raw file):

| postgres_oid
  {
    $$.val = $1.colType()

what was this doing? like assigning a variable as part of parsing somehow?

Copy link
Copy Markdown
Member Author

@jordanlewis jordanlewis 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 @RaduBerinde, @rafiss, and @spaskob)


pkg/sql/parser/sql.y, line 6756 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

what was this doing? like assigning a variable as part of parsing somehow?

So this functionality is actually preserved via the movement that I did - it used to be that postgres_oid was a typename but not a simple_typename. All simple_typenames are typenames, so what this change does is move postgres_oid to be a simple_typename. This has the ancillary benefit of automatically adding the array forms to the grammar, which was the point of this change.

The rule here I think was actually unnecessary. The $$.val = blah thing is used to set the "result" of the parsing rule. I think it's unnecessary if you're just exactly using the output of the rule that's matching.

Copy link
Copy Markdown
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

TFTR! Tried to explain below. We can talk more about grammar stuff offline if you want to learn more about how it works.

bors r+

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

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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis, @RaduBerinde, @rafiss, and @spaskob)


pkg/sql/parser/sql.y, line 6756 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

So this functionality is actually preserved via the movement that I did - it used to be that postgres_oid was a typename but not a simple_typename. All simple_typenames are typenames, so what this change does is move postgres_oid to be a simple_typename. This has the ancillary benefit of automatically adding the array forms to the grammar, which was the point of this change.

The rule here I think was actually unnecessary. The $$.val = blah thing is used to set the "result" of the parsing rule. I think it's unnecessary if you're just exactly using the output of the rule that's matching.

thanks! i understood the typename / simple_typename rules part of the change

craig bot pushed a commit that referenced this pull request Sep 25, 2019
40949: sql: remove last 2 blockers for pgcli support r=jordanlewis a=jordanlewis

```
sql: add syntax for arrays of oid wrapper types

Previously, syntax for the special oid wrapper types (like REGCLASS,
REGTYPE, and so on) was not available, despite the backend being able to
handle these types just fine.

This commit adds syntax for this (e.g. `select t::regclass[]`) to the
parser and hooks it up to the type system.
```

```
tree: add support for REGTYPE casts of the trigger type
```

Release note (sql change): support the syntax for oid wrapper arrays, like REGCLASS[], and REGTYPE casts for the unsupported `trigger` type.
Release justification: low risk, cosmetic compatibility improvement.


Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 25, 2019

Build succeeded

@craig craig bot merged commit 3dde922 into cockroachdb:master Sep 25, 2019
@awoods187
Copy link
Copy Markdown

excited about this!

@jordanlewis jordanlewis deleted the pgcli branch October 2, 2019 03:03
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.

4 participants