diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-10-31 00:26:04 +0200 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-10-31 00:26:04 +0200 |
commit | 842fc58e01bf856b0e175cceaf806b1d841e5e58 (patch) | |
tree | 0c64144980ba4322ba85480a7dcc30fcb321c23d /sql/ha_innodb.cc | |
parent | 35396ec7cd72580e952463a403f5105d2c3b6b62 (diff) | |
download | mariadb-git-842fc58e01bf856b0e175cceaf806b1d841e5e58.tar.gz |
ha_innodb.cc:
Fix bug in MySQL-3.23 ORDER BY from a table with no PRIMARY KEY and where the user had added UNIQUE indexes with CREATE INDEX
sql/ha_innodb.cc:
Fix bug in MySQL-3.23 ORDER BY from a table with no PRIMARY KEY and where the user had added UNIQUE indexes with CREATE INDEX
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r-- | sql/ha_innodb.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f4125f2259e..588c37e9cf3 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1171,7 +1171,10 @@ how you can resolve the problem.\n", ((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len = table->reclength; - primary_key = MAX_KEY; + /* Looks like MySQL-3.23 sometimes has primary key number != 0 */ + + primary_key = table->primary_key; + key_used_on_scan = primary_key; /* Allocate a buffer for a 'row reference'. A row reference is a string of bytes of length ref_length which uniquely specifies @@ -1180,13 +1183,14 @@ how you can resolve the problem.\n", of length ref_length! */ if (!row_table_got_default_clust_index(ib_table)) { + if (primary_key >= MAX_KEY) { + fprintf(stderr, + "InnoDB: Error: table %s has a primary key in InnoDB\n" + "InnoDB: data dictionary, but not in MySQL!\n", name); + } ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = FALSE; - - primary_key = 0; - key_used_on_scan = 0; - /* MySQL allocates the buffer for ref. key_info->key_length includes space for all key columns + one byte for each column @@ -1195,8 +1199,14 @@ how you can resolve the problem.\n", based on ref_length. */ - ref_length = table->key_info->key_length; + ref_length = table->key_info[primary_key].key_length; } else { + if (primary_key != MAX_KEY) { + fprintf(stderr, + "InnoDB: Error: table %s has no primary key in InnoDB\n" + "InnoDB: data dictionary, but has one in MySQL!\n", name); + } + ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = TRUE; @@ -1501,7 +1511,8 @@ ha_innobase::store_key_val_for_row( are equal */ bzero(buff, (ref_length- (uint) (buff - buff_start))); - DBUG_RETURN(ref_length); + + DBUG_RETURN((uint)(buff - buff_start)); } /****************************************************************** @@ -2759,7 +2770,11 @@ ha_innobase::position( that len is always fixed for this table. The following assertion checks this. */ - ut_a(len == ref_length); + if (len != ref_length) { + fprintf(stderr, + "InnoDB: Error: stored ref len is %lu, but table ref len is %lu\n", + (ulint)len, (ulint)ref_length); + } } |