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

Disable supports_expression_index unconditionally #250

Merged
merged 2 commits into from
May 11, 2022
Merged

Disable supports_expression_index unconditionally #250

merged 2 commits into from
May 11, 2022

Conversation

ecwall
Copy link
Contributor

@ecwall ecwall commented May 2, 2022

fixes cockroachdb/cockroach#67893
fixes cockroachdb/cockroach#80777

These can be enabled when CockroachDB supports "ON CONFLICT expression"

refs cockroachdb/cockroach#67893

@ecwall ecwall requested a review from otan May 2, 2022 23:42
@@ -181,7 +181,10 @@ def supports_partial_index?
end

def supports_expression_index?
@crdb_version >= 2122
# Expression indexes are partially supported by CockroachDB v21.2,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we do support it partially, then i would argue we should skip the test instead, or add a new condition for ON CONFLICT support and use that to skip the test / anything relevant in the ORM

otherwise, is this is a "regression" in ORM behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this to disable supports_insert_conflict_target? instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

we didn't need the public_send stuff right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like it is already there for the ones I overrode.

%w[
  supports_savepoints?
  supports_partial_index?
  supports_partitioned_indexes?
  supports_expression_index?
  supports_insert_returning?
  supports_insert_on_duplicate_skip?
  supports_insert_on_duplicate_update?
  supports_insert_conflict_target?
  supports_optimizer_hints?
  supports_datetime_with_precision?
].each do |method_name|
  define_method method_name do
    ActiveRecord::Base.connection.public_send(method_name)
  end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean it will also disable ON CONFLICT column_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it looks like there is no way to say we support expression indexes and ON CONFLICT column_name, but not ON CONFLICT expression without modifying activerecord itself.

@ecwall ecwall requested a review from otan May 3, 2022 11:59
@otan
Copy link
Contributor

otan commented May 3, 2022

[17:25:46][Step 2/2] Error:
[17:25:46][Step 2/2] InsertAllTest#test_upsert_all_does_notupdates_existing_record_by_when_there_is_no_key:
[17:25:46][Step 2/2] RuntimeError: Wrapped undumpable exception for: ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near ")": syntax error
[17:25:46][Step 2/2] DETAIL:  source SQL:
[17:25:46][Step 2/2] INSERT INTO "speedometers" ("speedometer_id","name") VALUES ('s3', 'New Speedometer') ON CONFLICT () DO UPDATE SET "speedometer_id"=excluded."speedometer_id","name"=excluded."name"
[17:25:46][Step 2/2]                                                                                                    ^
[17:25:46][Step 2/2] HINT:  try \h INSERT
[17:25:46][Step 2/2] 
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `exec_params'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `block (2 levels) in exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `block in exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:670:in `exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in `execute_and_clear'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:55:in `exec_query'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:154:in `exec_insert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in `exec_insert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/insert_all.rb:35:in `execute'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/persistence.rb:243:in `upsert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/test/cases/insert_all_test.rb:296:in `test_upsert_all_does_notupdates_existing_record_by_when_there_is_no_key'
[17:25:46][Step 2/2] 
[17:25:46][Step 2/2] rails test home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/test/cases/insert_all_test.rb:291

hmm, this failure seems suspicious

@ecwall
Copy link
Contributor Author

ecwall commented May 4, 2022

[17:25:46][Step 2/2] Error:
[17:25:46][Step 2/2] InsertAllTest#test_upsert_all_does_notupdates_existing_record_by_when_there_is_no_key:
[17:25:46][Step 2/2] RuntimeError: Wrapped undumpable exception for: ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  at or near ")": syntax error
[17:25:46][Step 2/2] DETAIL:  source SQL:
[17:25:46][Step 2/2] INSERT INTO "speedometers" ("speedometer_id","name") VALUES ('s3', 'New Speedometer') ON CONFLICT () DO UPDATE SET "speedometer_id"=excluded."speedometer_id","name"=excluded."name"
[17:25:46][Step 2/2]                                                                                                    ^
[17:25:46][Step 2/2] HINT:  try \h INSERT
[17:25:46][Step 2/2] 
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `exec_params'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `block (2 levels) in exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `block in exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:670:in `exec_no_cache'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in `execute_and_clear'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:55:in `exec_query'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:154:in `exec_insert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in `exec_insert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/insert_all.rb:35:in `execute'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/lib/active_record/persistence.rb:243:in `upsert_all'
[17:25:46][Step 2/2]     /home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/test/cases/insert_all_test.rb:296:in `test_upsert_all_does_notupdates_existing_record_by_when_there_is_no_key'
[17:25:46][Step 2/2] 
[17:25:46][Step 2/2] rails test home/agent/.gems/bundler/gems/rails-2eb631956768/activerecord/test/cases/insert_all_test.rb:291

hmm, this failure seems suspicious

Yeah it looks like I also had to disable supports_insert_on_duplicate_skip and supports_insert_on_duplicate_update.

However ON CONFLICT () isn't even valid in postgres so I'm not sure why that gets generated.

@ecwall ecwall changed the title Disable supports_expression_index until CockroachDB supports "ON CONFLICT expression" Disable supports_insert_on_duplicate_skip, supports_insert_conflict_target, supports_insert_on_duplicate_update until CockroachDB supports "ON CONFLICT expression" May 4, 2022
@ecwall ecwall changed the title Disable supports_insert_on_duplicate_skip, supports_insert_conflict_target, supports_insert_on_duplicate_update until CockroachDB supports "ON CONFLICT expression" Disable supports_insert_on_duplicate_skip, supports_insert_conflict_target, supports_insert_on_duplicate_update May 4, 2022
@ecwall ecwall requested a review from rafiss May 4, 2022 16:29
fixes cockroachdb/cockroach#67893
fixes cockroachdb/cockroach#80777

These can be enabled when CockroachDB supports "ON CONFLICT expression".

refs cockroachdb/cockroach#67893
@ecwall ecwall changed the title Disable supports_insert_on_duplicate_skip, supports_insert_conflict_target, supports_insert_on_duplicate_update Disable supports_expression_index unconditionally May 5, 2022
@ecwall ecwall merged commit afe639d into cockroachdb:master May 11, 2022
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.

sql: support expressions as ON CONFLICT targets roachtest: activerecord failed
3 participants