~stewart/drizzle/embedded-innodb-autoincrement

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/ha_pbxt.cc

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2628
2628
*/
2629
2629
 
2630
2630
/*
2631
 
 * write_row() inserts a row. No extra() hint is given currently if a bulk load
 
2631
 * doInsertRecord() inserts a row. No extra() hint is given currently if a bulk load
2632
2632
 * is happeneding. buf() is a byte array of data. You can use the field
2633
2633
 * information to extract the data from the native byte array type.
2634
2634
 * Example of this would be:
2641
2641
 * ha_berekly.cc has an example of how to store it intact by "packing" it
2642
2642
 * for ha_berkeley's own native storage type.
2643
2643
 
2644
 
 * See the note for update_row() on auto_increments and timestamps. This
2645
 
 * case also applied to write_row().
 
2644
 * See the note for doUpdateRecord() on auto_increments and timestamps. This
 
2645
 * case also applied to doInsertRecord().
2646
2646
 
2647
2647
 * Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc,
2648
2648
 * sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc.
2649
2649
 */
2650
 
int ha_pbxt::write_row(byte *buf)
 
2650
int ha_pbxt::doInsertRecord(byte *buf)
2651
2651
{
2652
2652
        int err = 0;
2653
2653
 
2654
2654
        ASSERT_NS(pb_ex_in_use);
2655
2655
 
2656
 
        XT_PRINT1(pb_open_tab->ot_thread, "write_row (%s)\n", pb_share->sh_table_path->ps_path);
 
2656
        XT_PRINT1(pb_open_tab->ot_thread, "doInsertRecord (%s)\n", pb_share->sh_table_path->ps_path);
2657
2657
        XT_DISABLED_TRACE(("INSERT tx=%d val=%d\n", (int) pb_open_tab->ot_thread->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&buf[1])));
2658
2658
        //statistic_increment(ha_write_count,&LOCK_status);
2659
2659
#ifdef PBMS_ENABLED
2660
2660
        PBMSResultRec result;
2661
 
        err = pbms_write_row_blobs(table, buf, &result);
 
2661
        err = pbms_doInsertRecord_blobs(table, buf, &result);
2662
2662
        if (err) {
2663
 
                xt_logf(XT_NT_ERROR, "pbms_write_row_blobs() Error: %s", result.mr_message);
 
2663
                xt_logf(XT_NT_ERROR, "pbms_doInsertRecord_blobs() Error: %s", result.mr_message);
2664
2664
                return err;
2665
2665
        }
2666
2666
#endif
2673
2673
                        /* Commit and restart the transaction. */
2674
2674
                        XTThreadPtr thread = pb_open_tab->ot_thread;
2675
2675
 
2676
 
                        XT_PRINT0(thread, "xt_xn_commit in write_row\n");
 
2676
                        XT_PRINT0(thread, "xt_xn_commit in doInsertRecord\n");
2677
2677
                        if (!xt_xn_commit(thread)) {
2678
2678
                                err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, thread, pb_ignore_dup_key);
2679
2679
                                return err;
2680
2680
                        }
2681
 
                        XT_PRINT0(thread, "xt_xn_begin in write_row\n");
 
2681
                        XT_PRINT0(thread, "xt_xn_begin in doInsertRecord\n");
2682
2682
                        if (!xt_xn_begin(thread)) {
2683
2683
                                err = xt_ha_pbxt_thread_error_for_mysql(pb_mysql_thd, thread, pb_ignore_dup_key);
2684
2684
                                return err;
2764
2764
#endif
2765
2765
 
2766
2766
/*
2767
 
 * Yes, update_row() does what you expect, it updates a row. old_data will have
 
2767
 * Yes, doUpdateRecord() does what you expect, it updates a row. old_data will have
2768
2768
 * the previous row record in it, while new_data will have the newest data in
2769
2769
 * it. Keep in mind that the server can do updates based on ordering if an ORDER BY
2770
2770
 * clause was used. Consecutive ordering is not guarenteed.
2771
2771
 *
2772
2772
 * Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc.
2773
2773
 */
2774
 
int ha_pbxt::update_row(const byte * old_data, byte * new_data)
 
2774
int ha_pbxt::doUpdateRecord(const byte * old_data, byte * new_data)
2775
2775
{
2776
2776
        int                                             err = 0;
2777
2777
        register XTThreadPtr    self = pb_open_tab->ot_thread;
2803
2803
                xt_logf(XT_NT_ERROR, "update_row:pbms_delete_row_blobs() Error: %s", result.mr_message);
2804
2804
                return err;
2805
2805
        }
2806
 
        err = pbms_write_row_blobs(table, new_data, &result);
 
2806
        err = pbms_doInsertRecord_blobs(table, new_data, &result);
2807
2807
        if (err) { 
2808
 
                xt_logf(XT_NT_ERROR, "update_row:pbms_write_row_blobs() Error: %s", result.mr_message);
 
2808
                xt_logf(XT_NT_ERROR, "update_row:pbms_doInsertRecord_blobs() Error: %s", result.mr_message);
2809
2809
                goto pbms_done;
2810
2810
        }
2811
2811
#endif
2850
2850
 * Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select it is
2851
2851
 * used for removing duplicates while in insert it is used for REPLACE calls.
2852
2852
*/
2853
 
int ha_pbxt::delete_row(const byte * buf)
 
2853
int ha_pbxt::doDeleteRecord(const byte * buf)
2854
2854
{
2855
2855
        int err = 0;
2856
2856
 
4735
4735
                                                 * this avoids taking locks on the rows that are read
4736
4736
                                                 * Which leads to the assertion failure:
4737
4737
                                                 * int XTRowLocks::xt_make_lock_permanent(XTOpenTable*, XTRowLockList*)(lock_xt.cc:646) item
4738
 
                                                 * after the transaction is committed in write_row.
 
4738
                                                 * after the transaction is committed in doInsertRecord.
4739
4739
                                                 */
4740
4740
                                                pb_open_tab->ot_for_update = FALSE;
4741
4741
                                                break;
4874
4874
                 *
4875
4875
                 * So, this is the correct place to start a statement transaction.
4876
4876
                 *
4877
 
                 * Note: if trans_register_ha() is not called before ha_write_row(), then 
 
4877
                 * Note: if trans_register_ha() is not called before insertRecord(), then 
4878
4878
                 * PBXT is not registered correctly as a modification transaction.
4879
 
                 * (mark_trx_read_write call in ha_write_row).
 
4879
                 * (mark_trx_read_write call in insertRecord).
4880
4880
                 * This leads to 2-phase commit not being called as it should when
4881
4881
                 * binary logging is enabled.
4882
4882
                 */