diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2017-05-04 18:51:19 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2017-05-04 18:51:19 +0200 |
commit | a2af3c0d44d919051c08b63cb10bed546d5f92a3 (patch) | |
tree | 57bfdacb584a38ed930c1aaa87d08fe8c9a83847 /storage/connect | |
parent | 6525dc63366f751fcfa45a586f378a1c81458657 (diff) | |
download | mariadb-git-a2af3c0d44d919051c08b63cb10bed546d5f92a3.tar.gz |
Fix MDEV-12653 Cannot add index for ZIP CONNECT table
modified: storage/connect/filamzip.cpp
modified: storage/connect/ha_connect.cc
modified: storage/connect/tabdos.cpp
modified: storage/connect/tabfmt.cpp
modified: storage/connect/tabjson.cpp
modified: storage/connect/xindex.cpp
Diffstat (limited to 'storage/connect')
-rw-r--r-- | storage/connect/filamzip.cpp | 8 | ||||
-rw-r--r-- | storage/connect/ha_connect.cc | 10 | ||||
-rw-r--r-- | storage/connect/tabdos.cpp | 4 | ||||
-rw-r--r-- | storage/connect/tabfmt.cpp | 2 | ||||
-rw-r--r-- | storage/connect/tabjson.cpp | 2 | ||||
-rwxr-xr-x | storage/connect/xindex.cpp | 4 |
6 files changed, 19 insertions, 11 deletions
diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index 66e628abb14..17ca84d9d5c 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -740,7 +740,13 @@ int UNZFAM::Cardinality(PGLOBAL g) int card = -1; int len = GetFileLength(g); - card = (len / (int)Lrecl) * 2; // Estimated ??? + if (len) { + // Estimated ??? + card = (len / (int)Lrecl) * 2; + card = card ? card : 10; // Lrecl can be too big + } else + card = 0; + return card; } // end of Cardinality diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 9f0b62c73b3..5245b2559c5 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -4601,10 +4601,12 @@ int ha_connect::external_lock(THD *thd, int lock_type) DBUG_RETURN(0); } else if (g->Xchk) { if (!tdbp) { - if (!(tdbp= GetTDB(g))) - DBUG_RETURN(HA_ERR_INTERNAL_ERROR); - else if (!tdbp->GetDef()->Indexable()) { - sprintf(g->Message, "external_lock: Table %s is not indexable", tdbp->GetName()); + if (!(tdbp = GetTDB(g))) { +// DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); + DBUG_RETURN(0); + } else if (!tdbp->GetDef()->Indexable()) { + sprintf(g->Message, "external_lock: Table %s is not indexable", tdbp->GetName()); // DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); DBUG_RETURN(0); diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index 02d3fc176ce..d6651fb21a9 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -353,7 +353,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) if (Zipped) { #if defined(ZIP_SUPPORT) if (Recfm == RECFM_VAR) { - if (mode == MODE_READ || mode == MODE_ANY) { + if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (mode == MODE_INSERT) { txfp = new(g) ZIPFAM(this); @@ -364,7 +364,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode) tdbp = new(g) TDBDOS(this, txfp); } else { - if (mode == MODE_READ || mode == MODE_ANY) { + if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) { txfp = new(g) UZXFAM(this); } else if (mode == MODE_INSERT) { txfp = new(g) ZPXFAM(this); diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index be288b3858d..ac85165d99f 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -517,7 +517,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode) /*******************************************************************/ if (Zipped) { #if defined(ZIP_SUPPORT) - if (mode == MODE_READ || mode == MODE_ANY) { + if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (mode == MODE_INSERT) { txfp = new(g) ZIPFAM(this); diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index e074232600b..9450f8d76aa 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -443,7 +443,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) if (Zipped) { #if defined(ZIP_SUPPORT) - if (m == MODE_READ || m == MODE_UPDATE) { + if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { txfp = new(g) UNZFAM(this); } else if (m == MODE_INSERT) { txfp = new(g) ZIPFAM(this); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index a2ddf468e5a..48edd12b3d8 100755 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -969,8 +969,8 @@ bool XINDEX::Init(PGLOBAL g) // For DBF tables, Cardinality includes bad or soft deleted lines // that are not included in the index, and can be larger then the // index size. - estim = (Tdbp->Ftype == RECFM_DBF); - n = Tdbp->Cardinality(g); // n is exact table size + estim = (Tdbp->Ftype == RECFM_DBF || Tdbp->Txfp->GetAmType() == TYPE_AM_ZIP); + n = Tdbp->Cardinality(g); // n is exact table size } else { // Variable table not optimized estim = true; // n is an estimate of the size |