summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-04-10 14:24:28 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-04-10 14:24:28 +0200
commit9b790248c5c1f4d8ef006ef2b7383aa41986c1a6 (patch)
tree5761e37162247e374ba2749c14d7572838246e35 /storage
parent6be6b4ab762bedbe08896252fe4a97d2aee2b0f9 (diff)
downloadmariadb-git-9b790248c5c1f4d8ef006ef2b7383aa41986c1a6.tar.gz
- Add routine to test index equality
modified: storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/xindex.h
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/ha_connect.cc28
-rw-r--r--storage/connect/ha_connect.h3
-rw-r--r--storage/connect/xindex.h1
3 files changed, 29 insertions, 3 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 7a949f89cbe..ec2863e1498 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -2988,6 +2988,30 @@ err:
return true;
}
+// Check that two indexes are equivalent
+bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2)
+{
+ bool b= true;
+ PKPDEF kp1, kp2;
+
+ if (stricmp(xp1->Name, xp2->Name))
+ b= false;
+ else if (xp1->Nparts != xp2->Nparts ||
+ xp1->MaxSame != xp2->MaxSame ||
+ xp1->Unique != xp2->Unique)
+ b= false;
+ else for (kp1= xp1->ToKeyParts, kp2= xp2->ToKeyParts;
+ b && (kp1 || kp2);
+ kp1= kp1->Next, kp2= kp2->Next)
+ if (!kp1 || !kp2)
+ b= false;
+ else if (stricmp(kp1->Name, kp2->Name))
+ b= false;
+ else if (kp1->Klen != kp2->Klen)
+ b= false;
+
+ return b;
+} // end of IsSameIndex
/**
@brief
@@ -3074,7 +3098,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
for (xp2= oldpix; xp2; xp2= xp) {
for (xp1= newpix; xp1; xp1= xp1->Next)
- if (!stricmp(xp1->Name, xp2->Name))
+ if (IsSameIndex(xp1, xp2))
break; // Index not to drop
xp= xp2->GetNext();
@@ -3107,7 +3131,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
for (xp1= newpix; xp1; xp1= xp) {
for (xp2= oldpix; xp2; xp2= xp2->Next)
- if (!stricmp(xp1->Name, xp2->Name))
+ if (IsSameIndex(xp1, xp2))
break; // Index already made
xp= xp1->Next;
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 147e326c632..3caf636232f 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -108,7 +108,8 @@ public:
int GetColNameLen(Field *fp);
char *GetColName(Field *fp);
void AddColName(char *cp, Field *fp);
- TABLE *GetTable(void) {return table;}
+ TABLE *GetTable(void) {return table;}
+ bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
PCONNECT GetUser(THD *thd);
PGLOBAL GetPlug(THD *thd);
diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h
index 6a2636d0ca5..6ff2b4be237 100644
--- a/storage/connect/xindex.h
+++ b/storage/connect/xindex.h
@@ -147,6 +147,7 @@ class DllExport KPARTDEF : public BLOCK { /* Index Key Part desc block */
friend class XINDEX;
friend class PLUGCAT;
friend class DOSDEF;
+ friend class ha_connect;
friend int PlgMakeIndex(PGLOBAL g, PSZ name, PIXDEF pxdf, bool add);
public:
KPARTDEF(PSZ name, int n); // Constructor