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: fix the match type reporting in information_schema.referential_constraints #35575

Merged
merged 1 commit into from
Mar 9, 2019

Conversation

knz
Copy link
Contributor

@knz knz commented Mar 9, 2019

This is the info_schema complement to #35052.

Release note (bug fix): CockroachDB now properly reports the composite
foreign key match type in information_schema.referential_constraints.

@knz knz requested review from bobvawter, BramGruneir and a team March 9, 2019 15:47
@cockroach-teamcity
Copy link
Member

This change is Reviewable

…onstraints

This is the info_schema complement to cockroachdb#35052.

Release note (bug fix): CockroachDB now properly reports the composite
foreign key match type in `information_schema.referential_constraints`.
@knz knz force-pushed the 20190309-fix-match-type branch from 727d745 to b7fe419 Compare March 9, 2019 15:48
Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bobvawter, @BramGruneir, and @knz)


pkg/sql/information_schema.go, line 632 at r1 (raw file):

					return err
				}
				var matchType tree.Datum = tree.DNull

Should the default be null and not none? Still strange that none is simple.

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

Should the default be null and not none? Still strange that none is simple.

I used the same values as in postgres. To my eyes the pg compatibility is most important. WDYT?

Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Oh, I agree, in PG it should be none for simple right?

But when should it ever be null? Every match needs a type.
We have the legacy of null for match type from way back before cascading was added, but those should be set to simple now.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bobvawter and @knz)

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

Oh, I agree, in PG it should be none for simple right?

Yes correct.

But when should it ever be null? Every match needs a type.

The value NULL will never occur in practice; it is used as fall-back when the matchOptionMap does not contain a mapping (which should be never - we have complete coverage there). The NULL fall-back is provided for a hypothetical future when someone forgets an entry in matchOptionMap and we want to avoid a panic in that case.

Does this clarify?

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

(we did the same in pg_catalog.pg_constraint.confmatch)

Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

What if fk.Match is empty?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bobvawter and @knz)

Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Looking at pg_catalog.pg_constraint, I think this needs to be fixed there too. If there is no match value, we must now assume that it is simple.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @bobvawter and @knz)

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

Can you double check?

When the descriptor does not have the Match field populated, it will decode with Match = 0 (the default value).

This is also the value you have chosen for ForeignKeyReference_SIMPLE. So descriptors without a match option will always resolve to Match == ForeignKeyReference_SIMPLE.

What is the case that's missing?

Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Ah, you're right. Carry on!

LGTM

:lgtm:

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

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

queue after #35583 merges

@knz
Copy link
Contributor Author

knz commented Mar 9, 2019

bors r+

craig bot pushed a commit that referenced this pull request Mar 9, 2019
35573: sql/parser: add a missing contextual help annotation r=knz a=knz

Release note: None

35575: sql: fix the match type reporting in information_schema.referential_constraints r=knz a=knz

This is the info_schema complement to #35052.

Release note (bug fix): CockroachDB now properly reports the composite
foreign key match type in `information_schema.referential_constraints`.

35577: sql: properly mark sequences as `bigint` in information_schema.sequences r=knz a=knz

Release note (bug fix): CockroachDB now properly reports `bigint`
in information_schema.sequences.type, for compatibility with PostgreSQL.

35578: sql: populate information_schema.table_privileges.with_hierarchy r=knz a=knz

Pg doc says:

*In the SQL standard, WITH HIERARCHY OPTION is a
separate (sub-)privilege allowing certain operations on table
inheritance hierarchies. In PostgreSQL, this is included in the SELECT
privilege, so this column shows YES if the privilege is SELECT, else
NO.*

https://www.postgresql.org/docs/9.5/infoschema-table-privileges.html

Release note: None

Co-authored-by: Raphael 'kena' Poss <[email protected]>
@craig
Copy link
Contributor

craig bot commented Mar 9, 2019

Build succeeded

@craig craig bot merged commit b7fe419 into cockroachdb:master Mar 9, 2019
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