On Thursday, July 23, 2015 at 3:42:19 PM UTC-7, Karl He wrote: > > Continuing from https://github.com/jeremyevans/sequel/issues/1048, sorry > about that. > > I have been running into issues in my migrations where DB2 will throw > errors about needing to REORG after certain alter_table statements. One > such sequence appears to be this: > > alter_table table do > add_column new_col_name, :varchar, :null => true > end > alter_table table do > set_column_allow_null new_col_name, false > end > alter_table table do > add_index new_col_name, :unique => true > end > alter_table table do > drop_index [:a, :b, :c, :d] > end > > Right before the add_index seems to be where it errors out: > > Sequel::DatabaseError: Java::ComIbmDb2JccAm::SqlException: Operation not > allowed for reason code "7" on table "...".. SQLCODE=-668, SQLSTATE=57016, > DRIVER=4.17.28 > > Same thing when I tried to bump the JDBC jar: > > Sequel::DatabaseError: Java::ComIbmDb2JccAm::SqlException: Operation not > allowed for reason code "7" on table "...".. SQLCODE=-668, SQLSTATE=57016, > DRIVER=4.19.26 > > So far I've been getting around it by manually running a reorg at whatever > points in the migration process it errors out: > > run "CALL SYSPROC.ADMIN_CMD( 'REORG TABLE table_name' )" > > You mentioned on the bug that the JDBC driver should be handling this. I > did find that there exists such an option: > > UPDATE DB CONFIG USING AUTO_MAINT ON AUTO_TBL_MAINT ON AUTO_RUNSTATS ON > AUTO_REORG ON > > However it isn't on by default, I also feel like it would make sense to > manually trigger it after a migration anyway. > > I couldn't track down any documentation regarding the DB2 JDBC driver > specifically handling REORG. Is there something else you were referring to? >
Nothing specific. I don't really know why, but in my testing REORG was only required when using the ibmdb adapter, not when using the jdbc/db2 or the old db2 adapters. If you want to send a pull request moving the automatic REORG code from the ibmdb adapter to the shared db2 adapter, I'll test it and merge it if it works. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
