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

release-19.2: sql: bevy of fixes for ActiveRecord compatibility #41447

Merged

Conversation

jordanlewis
Copy link
Member

Backport 6/6 commits from #41323.

/cc @cockroachdb/release


  • improve efficiency of 'foo'::REGCLASS
  • improve efficiency of pg_get_coldesc
  • parse INTERVAL(6) as a no-op meaning INTERVAL
  • bugfix to generate_subscripts for oidvector and int2vector
  • add pg_available_extensions
  • fix pg_get_indexdef and pg_attrdef.adbin to be more Postgres compatible

With these fixes, 90% of the fork in activerecord-cockroachdb-adapter can go away.

Previously, a 'foo'::regclass query used a really inefficient way of
determining the OID for a table named foo that involved getting all
descriptors. This was unnecessary - the data was actually already
available but not plumbed through properly.

Release justification: low risk fix to existing functionality
Release note (performance improvement): metadata queries that use the
'string'::regclass form are much more efficient in the presence of a
large number of tables.
This commit lets the parser accept the type INTERVAL(6) as a no-op
equivalent to INTERVAL. This is safe and equivalent to what we do for
INTERVAL on its own.

Updates cockroachdb#32564.

Release justification: low-risk compatibility fix
Release note (sql change): support interval precision syntax when the
requested precision is exactly 6, as a syntactic sugar for intervals
without a precision specified.
Closes cockroachdb#41264.

Release justification: low-risk compatibility improvement
Release note (sql change): add pg_available_extensions table
The special PG compatibility types int2vector and oidvector are
0-indexed, not 1-indexed like normal SQL arrays. generate_subscripts
needs to respect that. This commit makes it so.

Release justification: low-risk compatibility change
Release note (bug fix): the generate_subscripts builtin now behaves
properly on int2vector and oidvector types.
Previously, pg_get_coldesc would retrieve all comments to find a single
column comment. Now it retrieves precisely what it needs.

Release note (performance improvement): pg_get_coldesc is more efficient
Release justification: low-risk compatibility improvement
This commit improves compatibility for the pg_attrdef table by making
the default expression column less CockroachDB specific. Specifically,
CockroachDB normally includes a type annotation on default expressions.
Postgres doesn't do this, and doing it the CockroachDB way trips up
drivers unnecessarily. Now, we strip those type annotations for this
purpose only.

Also, improve compatibility for pg_get_indexdef by including the index
method in the returned CREATE INDEX statement. We return `btree` for the
default index type, even though that's a bit of a lie, in the name of
compatibility. `gin` is returned for inverted indexes as expected.

Release justification: low-risk compatibility improvement
Release note (sql change): improve compatibility for pg_attdef and
pg_get_indexdef functions.
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich
Copy link
Member

LGTM

@jordanlewis jordanlewis merged commit 58b9c0b into cockroachdb:release-19.2 Oct 8, 2019
@jordanlewis jordanlewis deleted the backport19.2-41323 branch October 8, 2019 21:33
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