~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to sql/ha_ndbcluster.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
  This program is free software; you can redistribute it and/or modify
4
4
  it under the terms of the GNU General Public License as published by
5
 
  the Free Software Foundation; either version 2 of the License, or
6
 
  (at your option) any later version.
 
5
  the Free Software Foundation; version 2 of the License.
7
6
 
8
7
  This program is distributed in the hope that it will be useful,
9
8
  but WITHOUT ANY WARRANTY; without even the implied warranty of
1107
1106
        error= create_unique_index(unique_index_name, key_info);
1108
1107
        break;
1109
1108
      case ORDERED_INDEX:
 
1109
        if (key_info->algorithm == HA_KEY_ALG_HASH)
 
1110
        {
 
1111
          push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
 
1112
                              ER_UNSUPPORTED_EXTENSION,
 
1113
                              ER(ER_UNSUPPORTED_EXTENSION),
 
1114
                              "Ndb does not support non-unique "
 
1115
                              "hash based indexes");
 
1116
          error= HA_ERR_UNSUPPORTED;
 
1117
          break;
 
1118
        }
1110
1119
        error= create_ordered_index(index_name, key_info);
1111
1120
        break;
1112
1121
      default:
1986
1995
          DBUG_PRINT("error", ("key %d unknown flag %d", j, p.key->flag));
1987
1996
          DBUG_ASSERT(FALSE);
1988
1997
          // Stop setting bounds but continue with what we have
1989
 
          op->end_of_bound(range_no);
1990
 
          DBUG_RETURN(0);
 
1998
          DBUG_RETURN(op->end_of_bound(range_no));
1991
1999
        }
1992
2000
      }
1993
2001
    }
2034
2042
 
2035
2043
    tot_len+= part_store_len;
2036
2044
  }
2037
 
  op->end_of_bound(range_no);
2038
 
  DBUG_RETURN(0);
 
2045
  DBUG_RETURN(op->end_of_bound(range_no));
2039
2046
}
2040
2047
 
2041
2048
/*
2956
2963
      DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error);
2957
2964
    }
2958
2965
    else if (type == UNIQUE_INDEX)
2959
 
    {
2960
 
      error= unique_index_scan(key_info, 
2961
 
                               start_key->key, 
2962
 
                               start_key->length, 
2963
 
                               buf);
2964
 
      DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error);
2965
 
    }
 
2966
      DBUG_RETURN(unique_index_scan(key_info, 
 
2967
                                    start_key->key, 
 
2968
                                    start_key->length, 
 
2969
                                    buf));
2966
2970
    break;
2967
2971
  default:
2968
2972
    break;
3138
3142
      size_t len = key_part->length;
3139
3143
      const byte * ptr = record + key_part->offset;
3140
3144
      Field *field = key_part->field;
3141
 
      if ((field->type() ==  MYSQL_TYPE_VARCHAR) &&
3142
 
          ((Field_varstring*)field)->length_bytes == 1)
 
3145
      if (field->type() ==  MYSQL_TYPE_VARCHAR)
3143
3146
      {
3144
 
        /** 
3145
 
         * Keys always use 2 bytes length
3146
 
         */
3147
 
        buff[0] = ptr[0];
3148
 
        buff[1] = 0;
3149
 
        memcpy(buff+2, ptr + 1, len);   
3150
 
        len += 2;
 
3147
        if (((Field_varstring*)field)->length_bytes == 1)
 
3148
        {
 
3149
          /**
 
3150
           * Keys always use 2 bytes length
 
3151
           */
 
3152
          buff[0] = ptr[0];
 
3153
          buff[1] = 0;
 
3154
          memcpy(buff+2, ptr + 1, len);
 
3155
        }
 
3156
        else
 
3157
        {
 
3158
          memcpy(buff, ptr, len + 2);
 
3159
        }
 
3160
        len += 2;
3151
3161
      }
3152
3162
      else
3153
3163
      {
3154
 
        memcpy(buff, ptr, len);
 
3164
        memcpy(buff, ptr, len);
3155
3165
      }
3156
3166
      buff += len;
3157
3167
    }
3870
3880
      ERR_RETURN(ndb->getNdbError());
3871
3881
    no_uncommitted_rows_reset(thd);
3872
3882
    thd_ndb->stmt= trans;
 
3883
    thd_ndb->query_state&= NDB_QUERY_NORMAL;
3873
3884
    trans_register_ha(thd, FALSE, &ndbcluster_hton);
3874
3885
  }
3875
 
  thd_ndb->query_state&= NDB_QUERY_NORMAL;
3876
3886
  m_active_trans= trans;
3877
 
 
3878
3887
  // Start of statement
3879
3888
  m_retrieve_all_fields= FALSE;
3880
3889
  m_retrieve_primary_key= FALSE;
4173
4182
      col.setType(NDBCOL::Text);
4174
4183
      col.setCharset(cs);
4175
4184
    }
4176
 
    // Use "<=" even if "<" is the exact condition
4177
 
    if (field->max_length() <= (1 << 8))
4178
 
      goto mysql_type_tiny_blob;
4179
 
    else if (field->max_length() <= (1 << 16))
4180
4185
    {
4181
 
      col.setInlineSize(256);
4182
 
      col.setPartSize(2000);
4183
 
      col.setStripeSize(16);
 
4186
      Field_blob *field_blob= (Field_blob *)field;
 
4187
      /*
 
4188
       * max_data_length is 2^8-1, 2^16-1, 2^24-1 for tiny, blob, medium.
 
4189
       * Tinyblob gets no blob parts.  The other cases are just a crude
 
4190
       * way to control part size and striping.
 
4191
       *
 
4192
       * In mysql blob(256) is promoted to blob(65535) so it does not
 
4193
       * in fact fit "inline" in NDB.
 
4194
       */
 
4195
      if (field_blob->max_data_length() < (1 << 8))
 
4196
        goto mysql_type_tiny_blob;
 
4197
      else if (field_blob->max_data_length() < (1 << 16))
 
4198
      {
 
4199
        col.setInlineSize(256);
 
4200
        col.setPartSize(2000);
 
4201
        col.setStripeSize(16);
 
4202
      }
 
4203
      else if (field_blob->max_data_length() < (1 << 24))
 
4204
        goto mysql_type_medium_blob;
 
4205
      else
 
4206
        goto mysql_type_long_blob;
4184
4207
    }
4185
 
    else if (field->max_length() <= (1 << 24))
4186
 
      goto mysql_type_medium_blob;
4187
 
    else
4188
 
      goto mysql_type_long_blob;
4189
4208
    break;
4190
4209
  mysql_type_medium_blob:
4191
4210
  case MYSQL_TYPE_MEDIUM_BLOB:   
5822
5841
 
5823
5842
  if (!is_autocommit)
5824
5843
  {
5825
 
    DBUG_PRINT("exit", ("Can't register table during transaction"))
 
5844
    DBUG_PRINT("exit", ("Can't register table during transaction"));
5826
5845
    DBUG_RETURN(FALSE);
5827
5846
  }
5828
5847
 
5829
5848
  if (ndb_get_commitcount(thd, m_dbname, m_tabname, &commit_count))
5830
5849
  {
5831
5850
    *engine_data= 0;
5832
 
    DBUG_PRINT("exit", ("Error, could not get commitcount"))
 
5851
    DBUG_PRINT("exit", ("Error, could not get commitcount"));
5833
5852
    DBUG_RETURN(FALSE);
5834
5853
  }
5835
5854
  *engine_data= commit_count;
6112
6131
retry:
6113
6132
    if(report_error)
6114
6133
    {
6115
 
      if (file)
 
6134
      if (file && pTrans)
6116
6135
      {
6117
6136
        reterr= file->ndb_err(pTrans);
6118
6137
      }
6343
6362
        }
6344
6363
        else if ((scanOp= m_active_trans->getNdbIndexScanOperation(idx, tab)) 
6345
6364
                 &&!scanOp->readTuples(lm, 0, parallelism, sorted, 
6346
 
                                       FALSE, TRUE, need_pk)
 
6365
                                       FALSE, TRUE, need_pk, TRUE)
6347
6366
                 &&!generate_scan_filter(m_cond_stack, scanOp)
6348
6367
                 &&!define_read_attrs(end_of_buffer-reclength, scanOp))
6349
6368
        {
6506
6525
  }
6507
6526
  
6508
6527
  if (multi_range_curr == multi_range_end)
 
6528
  {
 
6529
    Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
 
6530
    thd_ndb->query_state&= NDB_QUERY_NORMAL;
6509
6531
    DBUG_RETURN(HA_ERR_END_OF_FILE);
 
6532
  }
6510
6533
  
6511
6534
  /**
6512
6535
   * Read remaining ranges