rails/rails — Issue #3902: test_rename_table_with_prefix_and_suffix got a error every other execution
Author: yahonda
Created: 2011-12-08 07:51:48+00:00
State: open

test_rename_table_with_prefix_and_suffix got a error every other execution. Not every time, every other time.

```ruby
$ cd activerecord
$ rake test_oracle
... snip ...

1) Error:
test_rename_table_with_prefix_and_suffix(MigrationTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00955: name is already used by an existing object: CREATE SEQUENCE "PREFIX_THINGS_SUFFIX_SEQ" START WITH 10000
stmt.c:312:in oci8lib_191.so
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/gems/ruby-oci8-2.0.6/lib/oci8/oci8.rb:288:in `exec'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/gems/ruby-oci8-2.0.6/lib/oci8/oci8.rb:116:in `exec'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:469:in `exec'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:88:in `exec'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:590:in `block in execute'
/home/yahonda/Dropbox/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/yahonda/Dropbox/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/yahonda/Dropbox/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1303:in `log'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:590:in `execute'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb:334:in `create_sequence_and_trigger'
/home/yahonda/.rvm/gems/ruby-1.9.3-p0@rails_master/bundler/gems/oracle-enhanced-d3975cac15d9/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb:91:in `create_table'
/home/yahonda/Dropbox/git/rails/activerecord/lib/active_record/migration.rb:449:in `block in method_missing'
/home/yahonda/Dropbox/git/rails/activerecord/lib/active_record/migration.rb:423:in `block in say_with_time'

3147 tests, 9660 assertions, 0 failures, 1 errors, 0 skips
rake aborted!
Command failed with status (1): [/home/yahonda/.rvm/rubies/ruby-1.9.3-p0/bi...]

Tasks: TOP => test_oracle
(See full trace by running task with --trace)
[yahonda@worksl6 activerecord]$
```

debug.log says
RENAME "PREFIX_THINGS_SUFFIX" to "PREFIX_AWESOME_THINGS_SUFFIX" finishes successfully.
but RENAME "PREFIX_THINGS_SUFFIX_SEQ" TO "PREFIX_AWESOME_THINGS_SUFFIX_SEQ" got
an ORA-00972 error because the new sequence name length is 32byte(30byte is the limit).

Therefore the original sequence "PREFIX_THINGS_SUFFIX_SEQ" exists after rename operation failed.
Then the next time execution, create sequence fails because it already exists.

debug.log

```sql
D, [2011-12-08T02:33:26.202272 #7475] DEBUG -- : (31.0ms) RENAME "PREFIX_THINGS_SUFFIX" TO "PREFIX_AWESOME_THINGS_SUFFIX"
D, [2011-12-08T02:33:26.205356 #7475] DEBUG -- : (2.6ms) RENAME "PREFIX_THINGS_SUFFIX_SEQ" TO "PREFIX_AWESOME_THINGS_SUFFIX_SEQ"
D, [2011-12-08T02:33:26.205470 #7475] DEBUG -- : OCIError: ORA-00972: identifier is too long: RENAME "PREFIX_THINGS_SUFFIX_SEQ" TO "PREFIX_AWESOME_THINGS_SUFFIX_SEQ"
```