~clint-fewbar/ubuntu/natty/mysql-5.1/merge-5.1.49-2

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/row/row0sel.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-08-04 13:18:27 UTC
  • mfrom: (1.2.2 upstream) (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100804131827-4tjg88vr9dd49s3k
Tags: 5.1.49-1ubuntu1
* Merge from debian unstable:
  + debian/control:
     * Update maintainer according to spec.
     * Move section from "misc" to "database".
     * Added libmysqlclient16-dev an empty transitional package. 
     * Added mysql-client-core-5.1 package.
     * Suggest mailx for mysql-server-5.1
     * Add mysql-testsuite package so you can run the testsuite seperately.
  + debian/additions/my.cnf:
    * Remove language options. Error message files are located in a different directory in Mysql
      5.0. Setting the language option to use /usr/share/mysql/english breaks Mysql 5.0. Both 5.0
      and 5.1 use a different value that works. (LP: #316974)
  + Add apparmor profile:
    + debian/apparmor-profile: apparmor-profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-server-5.1.postinst: reload apparmor profiles
  * Convert the package from sysvinit to upstart:
    + debian/mysql-server-5.1.mysql.upstart: Add upstart script.
    + debian/mysql-server-5.1.mysql.init: Dropped, unused now with upstart.
    + debian/additions/mysqld_safe_syslog.cnf: Dropped, unused now with upstart.
    + debian/additons/my.cnf: Remove pid declaration and setup error logging to /var/log/mysql since
      we're not piping anything around logger anymore.
    + debian/rules, debian/mysql-server-5.1.logcheck.ignore.{paranoid,worstation},
      debian/mysql-server-5.1.logcheck.ignore.server: : Remove references to mysqld_safe
    + debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch: Dropped
  * Added -fno-strict-aliasing to CFLAGS to get around mysql testsuite build failures.
  * Add Apport hook (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/rules: Make it installable
  * debian/mysql-server-5.1.mysql-server.logrotate: Check to see if mysql is running before
    running logrotate. (LP: #513135)
  * Make the testsuite installable. (LP: #530752)
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  * debian/mysql-server-5.1.preinst: Set mysql user's home directory
    to /nonexistent to protect against having the /var/lib/mysql
    user-writeable. If an attacker can trick mysqld into creating
    dot files in the home directory, he could do .rhost-like attacks
    on the system. (LP: #293258)
  * debian/control: mysql-client-5.1 should depend on mysql-core-client-5.1.
    (LP: #590952) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
863
863
                        clust_rec, index, offsets,
864
864
                        node->row_lock_mode, lock_type, thr);
865
865
 
866
 
                if (err != DB_SUCCESS) {
867
 
 
 
866
                switch (err) {
 
867
                case DB_SUCCESS:
 
868
                case DB_SUCCESS_LOCKED_REC:
 
869
                        /* Declare the variable uninitialized in Valgrind.
 
870
                        It should be set to DB_SUCCESS at func_exit. */
 
871
                        UNIV_MEM_INVALID(&err, sizeof err);
 
872
                        break;
 
873
                default:
868
874
                        goto err_exit;
869
875
                }
870
876
        } else {
934
940
 
935
941
/*********************************************************************//**
936
942
Sets a lock on a record.
937
 
@return DB_SUCCESS or error code */
 
943
@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */
938
944
UNIV_INLINE
939
 
ulint
 
945
enum db_err
940
946
sel_set_rec_lock(
941
947
/*=============*/
942
948
        const buf_block_t*      block,  /*!< in: buffer block of rec */
948
954
                                        LOC_REC_NOT_GAP */
949
955
        que_thr_t*              thr)    /*!< in: query thread */
950
956
{
951
 
        trx_t*  trx;
952
 
        ulint   err;
 
957
        trx_t*          trx;
 
958
        enum db_err     err;
953
959
 
954
960
        trx = thr_get_trx(thr);
955
961
 
1482
1488
                                               node->row_lock_mode,
1483
1489
                                               lock_type, thr);
1484
1490
 
1485
 
                        if (err != DB_SUCCESS) {
 
1491
                        switch (err) {
 
1492
                        case DB_SUCCESS_LOCKED_REC:
 
1493
                                err = DB_SUCCESS;
 
1494
                        case DB_SUCCESS:
 
1495
                                break;
 
1496
                        default:
1486
1497
                                /* Note that in this case we will store in pcur
1487
1498
                                the PREDECESSOR of the record we are waiting
1488
1499
                                the lock for */
1489
 
 
1490
1500
                                goto lock_wait_or_error;
1491
1501
                        }
1492
1502
                }
1538
1548
                                       rec, index, offsets,
1539
1549
                                       node->row_lock_mode, lock_type, thr);
1540
1550
 
1541
 
                if (err != DB_SUCCESS) {
1542
 
 
 
1551
                switch (err) {
 
1552
                case DB_SUCCESS_LOCKED_REC:
 
1553
                        err = DB_SUCCESS;
 
1554
                case DB_SUCCESS:
 
1555
                        break;
 
1556
                default:
1543
1557
                        goto lock_wait_or_error;
1544
1558
                }
1545
1559
        }
2664
2678
                prebuilt->blob_heap = NULL;
2665
2679
        }
2666
2680
 
 
2681
        /* init null bytes with default values as they might be
 
2682
        left uninitialized in some cases and these uninited bytes
 
2683
        might be copied into mysql record buffer that leads to
 
2684
        valgrind warnings */
 
2685
        memcpy(mysql_rec, prebuilt->default_rec, prebuilt->null_bitmap_len);
 
2686
 
2667
2687
        for (i = 0; i < prebuilt->n_template; i++) {
2668
2688
 
2669
2689
                templ = prebuilt->mysql_template + i;
2801
2821
Retrieves the clustered index record corresponding to a record in a
2802
2822
non-clustered index. Does the necessary locking. Used in the MySQL
2803
2823
interface.
2804
 
@return DB_SUCCESS or error code */
 
2824
@return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */
2805
2825
static
2806
 
ulint
 
2826
enum db_err
2807
2827
row_sel_get_clust_rec_for_mysql(
2808
2828
/*============================*/
2809
2829
        row_prebuilt_t* prebuilt,/*!< in: prebuilt struct in the handle */
2830
2850
        dict_index_t*   clust_index;
2831
2851
        const rec_t*    clust_rec;
2832
2852
        rec_t*          old_vers;
2833
 
        ulint           err;
 
2853
        enum db_err     err;
2834
2854
        trx_t*          trx;
2835
2855
 
2836
2856
        *out_rec = NULL;
2889
2909
 
2890
2910
                clust_rec = NULL;
2891
2911
 
 
2912
                err = DB_SUCCESS;
2892
2913
                goto func_exit;
2893
2914
        }
2894
2915
 
2904
2925
                        0, btr_pcur_get_block(prebuilt->clust_pcur),
2905
2926
                        clust_rec, clust_index, *offsets,
2906
2927
                        prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr);
2907
 
                if (err != DB_SUCCESS) {
2908
 
 
 
2928
                switch (err) {
 
2929
                case DB_SUCCESS:
 
2930
                case DB_SUCCESS_LOCKED_REC:
 
2931
                        break;
 
2932
                default:
2909
2933
                        goto err_exit;
2910
2934
                }
2911
2935
        } else {
2965
2989
                                     rec, sec_index, clust_rec, clust_index));
2966
2990
#endif
2967
2991
                }
 
2992
 
 
2993
                err = DB_SUCCESS;
2968
2994
        }
2969
2995
 
2970
2996
func_exit:
2977
3003
                btr_pcur_store_position(prebuilt->clust_pcur, mtr);
2978
3004
        }
2979
3005
 
2980
 
        err = DB_SUCCESS;
2981
3006
err_exit:
2982
3007
        return(err);
2983
3008
}
3702
3727
                                               prebuilt->select_lock_type,
3703
3728
                                               LOCK_GAP, thr);
3704
3729
 
3705
 
                        if (err != DB_SUCCESS) {
3706
 
 
 
3730
                        switch (err) {
 
3731
                        case DB_SUCCESS_LOCKED_REC:
 
3732
                                err = DB_SUCCESS;
 
3733
                        case DB_SUCCESS:
 
3734
                                break;
 
3735
                        default:
3707
3736
                                goto lock_wait_or_error;
3708
3737
                        }
3709
3738
                }
3801
3830
                                               prebuilt->select_lock_type,
3802
3831
                                               LOCK_ORDINARY, thr);
3803
3832
 
3804
 
                        if (err != DB_SUCCESS) {
3805
 
 
 
3833
                        switch (err) {
 
3834
                        case DB_SUCCESS_LOCKED_REC:
 
3835
                                err = DB_SUCCESS;
 
3836
                        case DB_SUCCESS:
 
3837
                                break;
 
3838
                        default:
3806
3839
                                goto lock_wait_or_error;
3807
3840
                        }
3808
3841
                }
3932
3965
                                        prebuilt->select_lock_type, LOCK_GAP,
3933
3966
                                        thr);
3934
3967
 
3935
 
                                if (err != DB_SUCCESS) {
3936
 
 
 
3968
                                switch (err) {
 
3969
                                case DB_SUCCESS_LOCKED_REC:
 
3970
                                case DB_SUCCESS:
 
3971
                                        break;
 
3972
                                default:
3937
3973
                                        goto lock_wait_or_error;
3938
3974
                                }
3939
3975
                        }
3968
4004
                                        prebuilt->select_lock_type, LOCK_GAP,
3969
4005
                                        thr);
3970
4006
 
3971
 
                                if (err != DB_SUCCESS) {
3972
 
 
 
4007
                                switch (err) {
 
4008
                                case DB_SUCCESS_LOCKED_REC:
 
4009
                                case DB_SUCCESS:
 
4010
                                        break;
 
4011
                                default:
3973
4012
                                        goto lock_wait_or_error;
3974
4013
                                }
3975
4014
                        }
4039
4078
 
4040
4079
                switch (err) {
4041
4080
                        const rec_t*    old_vers;
4042
 
                case DB_SUCCESS:
 
4081
                case DB_SUCCESS_LOCKED_REC:
4043
4082
                        if (srv_locks_unsafe_for_binlog
4044
 
                            || trx->isolation_level <= TRX_ISO_READ_COMMITTED) {
 
4083
                            || trx->isolation_level
 
4084
                            <= TRX_ISO_READ_COMMITTED) {
4045
4085
                                /* Note that a record of
4046
4086
                                prebuilt->index was locked. */
4047
4087
                                prebuilt->new_rec_locks = 1;
4048
4088
                        }
 
4089
                        err = DB_SUCCESS;
 
4090
                case DB_SUCCESS:
4049
4091
                        break;
4050
4092
                case DB_LOCK_WAIT:
 
4093
                        /* Never unlock rows that were part of a conflict. */
 
4094
                        prebuilt->new_rec_locks = 0;
 
4095
 
4051
4096
                        if (UNIV_LIKELY(prebuilt->row_read_type
4052
4097
                                        != ROW_READ_TRY_SEMI_CONSISTENT)
4053
4098
                            || unique_search
4077
4122
                        if (UNIV_LIKELY(trx->wait_lock != NULL)) {
4078
4123
                                lock_cancel_waiting_and_release(
4079
4124
                                        trx->wait_lock);
4080
 
                                prebuilt->new_rec_locks = 0;
4081
4125
                        } else {
4082
4126
                                mutex_exit(&kernel_mutex);
4083
4127
 
4089
4133
                                                          ULINT_UNDEFINED,
4090
4134
                                                          &heap);
4091
4135
                                err = DB_SUCCESS;
4092
 
                                /* Note that a record of
4093
 
                                prebuilt->index was locked. */
4094
 
                                prebuilt->new_rec_locks = 1;
4095
4136
                                break;
4096
4137
                        }
4097
4138
                        mutex_exit(&kernel_mutex);
4228
4269
                err = row_sel_get_clust_rec_for_mysql(prebuilt, index, rec,
4229
4270
                                                      thr, &clust_rec,
4230
4271
                                                      &offsets, &heap, &mtr);
4231
 
                if (err != DB_SUCCESS) {
 
4272
                switch (err) {
 
4273
                case DB_SUCCESS:
 
4274
                        if (clust_rec == NULL) {
 
4275
                                /* The record did not exist in the read view */
 
4276
                                ut_ad(prebuilt->select_lock_type == LOCK_NONE);
4232
4277
 
 
4278
                                goto next_rec;
 
4279
                        }
 
4280
                        break;
 
4281
                case DB_SUCCESS_LOCKED_REC:
 
4282
                        ut_a(clust_rec != NULL);
 
4283
                        if (srv_locks_unsafe_for_binlog
 
4284
                             || trx->isolation_level
 
4285
                            <= TRX_ISO_READ_COMMITTED) {
 
4286
                                /* Note that the clustered index record
 
4287
                                was locked. */
 
4288
                                prebuilt->new_rec_locks = 2;
 
4289
                        }
 
4290
                        err = DB_SUCCESS;
 
4291
                        break;
 
4292
                default:
4233
4293
                        goto lock_wait_or_error;
4234
4294
                }
4235
4295
 
4236
 
                if (clust_rec == NULL) {
4237
 
                        /* The record did not exist in the read view */
4238
 
                        ut_ad(prebuilt->select_lock_type == LOCK_NONE);
4239
 
 
4240
 
                        goto next_rec;
4241
 
                }
4242
 
 
4243
 
                if ((srv_locks_unsafe_for_binlog
4244
 
                     || trx->isolation_level <= TRX_ISO_READ_COMMITTED)
4245
 
                    && prebuilt->select_lock_type != LOCK_NONE) {
4246
 
                        /* Note that both the secondary index record
4247
 
                        and the clustered index record were locked. */
4248
 
                        ut_ad(prebuilt->new_rec_locks == 1);
4249
 
                        prebuilt->new_rec_locks = 2;
4250
 
                }
4251
 
 
4252
4296
                if (UNIV_UNLIKELY(rec_get_deleted_flag(clust_rec, comp))) {
4253
4297
 
4254
4298
                        /* The record is delete marked: we can skip it */