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: parse partial indexes #49335

Merged
merged 1 commit into from
May 22, 2020
Merged

Conversation

mgartner
Copy link
Collaborator

This commit adds support for parsing partial indexes. The parser can now
parse statements like:

CREATE TABLE t (a INT, INDEX (a) WHERE a > 3)
CREATE TABLE t (a INT, UNIQUE INDEX (a) WHERE a > 3)
CREATE INDEX i ON t (a) WHERE a > 3

Note that these WHERE clauses have no effect as of this commit. Until
further work is done, the WHERE clauses are ignored and full indexes
are created.

This commit also adds the ability to format the Predicate expression
of tree.CreateIndex and tree.IndexTableDef expressions.

A temporary session setting has been added called partial_indexes.
When set to true, it enables the user to create partial indexes. By
default, it is false because partial indexes are not fully supported.
Once partial indexes are fully functional, this setting will be removed.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner mgartner requested review from RaduBerinde and rytaft May 20, 2020 17:50
Copy link
Collaborator

@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.

:lgtm:

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

@mgartner mgartner force-pushed the parse-partial-index branch from 27fa106 to 49b2930 Compare May 20, 2020 20:53
Copy link
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.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)


pkg/sql/create_index.go, line 203 at r2 (raw file):

	// TODO(mgartner): remove this once partial indexes are fully supported.
	if n.Predicate != nil && !params.SessionData().PartialIndexes {
		return nil, pgerror.New(pgcode.FeatureNotSupported, "partial indexes are not supported")

The old error mentioned issue 9683, we should still do that, you can use unimplemented.NewWithIssue


pkg/sql/vars.go, line 608 at r2 (raw file):

	// CockroachDB extension.
	// TODO(mgartner): remove this once partial indexes are fully supported.
	`partial_indexes`: {

make it experimental_partial_indexes for now

@mgartner mgartner force-pushed the parse-partial-index branch from 49b2930 to ea6c7fe Compare May 21, 2020 23:26
@mgartner mgartner requested a review from a team as a code owner May 21, 2020 23:26
Copy link
Collaborator Author

@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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @rytaft)


pkg/sql/create_index.go, line 203 at r2 (raw file):

Previously, RaduBerinde wrote…

The old error mentioned issue 9683, we should still do that, you can use unimplemented.NewWithIssue

Done.


pkg/sql/vars.go, line 608 at r2 (raw file):

Previously, RaduBerinde wrote…

make it experimental_partial_indexes for now

Done.

This commit adds support for parsing partial indexes. The parser can now
parse statements like:

    CREATE TABLE t (a INT, INDEX (a) WHERE a > 3)
    CREATE TABLE t (a INT, UNIQUE INDEX (a) WHERE a > 3)
    CREATE INDEX i ON t (a) WHERE a > 3

Note that these `WHERE` clauses have no effect as of this commit. Until
further work is done, the `WHERE` clauses are ignored and full indexes
are created.

This commit also adds the ability to format the `Predicate` expression
of `tree.CreateIndex` and `tree.IndexTableDef` expressions.

A temporary session setting has been added called `partial_indexes`.
When set to true, it enables the user to create partial indexes. By
default, it is false because partial indexes are not fully supported.
Once partial indexes are fully functional, this setting will be removed.

Release note: None
@mgartner mgartner force-pushed the parse-partial-index branch from ea6c7fe to b774f2e Compare May 21, 2020 23:49
Copy link
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.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @rytaft)

@mgartner
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented May 22, 2020

Build succeeded

@craig craig bot merged commit d7985c5 into cockroachdb:master May 22, 2020
@mgartner mgartner deleted the parse-partial-index branch May 22, 2020 01:39
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