~vkolesnikov/pbxt/pbxt-maria-windows-app-ver-fixes

« back to all changes in this revision

Viewing changes to src/ha_pbxt.cc

  • Committer: Paul McCullagh
  • Date: 2010-08-31 15:54:47 UTC
  • Revision ID: paul.mccullagh@primebase.org-20100831155447-utg6bki31sw4txq0
Made a change to reduce the time that only temporary tables exist during the ALTER TABLE and REPAIR TABLE statements

Show diffs side-by-side

added added

removed removed

Lines of Context:
2298
2298
                                         */
2299
2299
                                        if (!thd || thd_sql_command(thd) == SQLCOM_FLUSH) // FLUSH TABLES
2300
2300
                                                xt_sync_flush_table(self, ot);
 
2301
                                        else {
 
2302
                                                /* This change is a result of a problem mentioned by Arjen.
 
2303
                                                 * REPAIR and ALTER lead to the following sequence:
 
2304
                                                 * 1. tab  -- copy --> tmp1
 
2305
                                                 * 2. tab  -- rename --> tmp2
 
2306
                                                 * 3. tmp1 -- rename --> tab
 
2307
                                                 * 4. delete tmp2
 
2308
                                                 *
 
2309
                                                 * PBXT flushes a table before rename.
 
2310
                                                 * In the sequence above results in a table flush in step 3 which can
 
2311
                                                 * take a very long time.
 
2312
                                                 *
 
2313
                                                 * The problem is, during this time frame we have only temp tables.
 
2314
                                                 * A crash in this state leaves the database in a bad state.
 
2315
                                                 *
 
2316
                                                 * To reduce the time in this state, the flush needs to be done
 
2317
                                                 * elsewhere. The code below causes the flish to occur after
 
2318
                                                 * step 1:
 
2319
                                                 */ 
 
2320
                                                switch (thd_sql_command(thd)) {
 
2321
                                                        case SQLCOM_REPAIR:
 
2322
                                                        case SQLCOM_RENAME_TABLE:
 
2323
                                                        case SQLCOM_OPTIMIZE:
 
2324
                                                        case SQLCOM_ANALYZE:
 
2325
                                                        case SQLCOM_ALTER_TABLE:
 
2326
                                                        case SQLCOM_CREATE_INDEX:
 
2327
                                                                xt_sync_flush_table(self, ot);
 
2328
                                                                break;
 
2329
                                                }
 
2330
                                        }
2301
2331
                                }
2302
2332
                                freer_(); // xt_db_return_table_to_pool(ot);
2303
2333
                        }