summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2002-10-31 00:30:19 +0200
committerunknown <heikki@hundin.mysql.fi>2002-10-31 00:30:19 +0200
commit8ade6771d79a0cebbbe6560b77cae257d72ac958 (patch)
tree77352f4125cbc64e2ba2d2c5da648b616052f13f
parent360b64379daf7d485d43089d4e42dc891b09e1b1 (diff)
downloadmariadb-git-8ade6771d79a0cebbbe6560b77cae257d72ac958.tar.gz
ha_innobase.cc:
Backport from 4.0: 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 pars0grm.y: Move inclusion of math.h after univ.i also in the .y file; this fix is already done in 4.0 innobase/pars/pars0grm.y: Move inclusion of math.h after univ.i also in the .y file; this fix is already done in 4.0 sql/ha_innobase.cc: Backport from 4.0: 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
-rw-r--r--innobase/pars/pars0grm.y3
-rw-r--r--sql/ha_innobase.cc36
2 files changed, 25 insertions, 14 deletions
diff --git a/innobase/pars/pars0grm.y b/innobase/pars/pars0grm.y
index 67289222594..eedc42bee57 100644
--- a/innobase/pars/pars0grm.y
+++ b/innobase/pars/pars0grm.y
@@ -14,9 +14,8 @@ the InnoDB parser.
/* The value of the semantic attribute is a pointer to a query tree node
que_node_t */
-#include <math.h>
-
#include "univ.i"
+#include <math.h>
#include "pars0pars.h"
#include "mem0mem.h"
#include "que0types.h"
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 13912ad5919..6b5ba7d841e 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -993,7 +993,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
@@ -1002,21 +1005,30 @@ 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
- that may be NULL. ref_length must be as exact as possible to
- save space, because all row reference buffers are allocated
- based on ref_length. */
-
- ref_length = table->key_info->key_length;
+ /*
+ MySQL allocates the buffer for ref. key_info->key_length
+ includes space for all key columns + one byte for each column
+ that may be NULL. ref_length must be as exact as possible to
+ save space, because all row reference buffers are allocated
+ based on ref_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;