Skip to content

Commit 5c2c68d

Browse files
committed
This is a major update concerning many source files.
Fix MDEV-12035. modified: storage/connect/jsonudf.cpp Working on MDEV-11832: Srcdef performance enhancement This require to mark place holders into srcdef to indicate where to insert the where/having clauses that are retrieved in push_cond. However this also make necessary to handle aliases in the srcdef. This was the opportunity to base all external tables on common classes called EXTDEF, TABEXT and EXTCOL. modified: storage/connect/array.cpp modified: storage/connect/array.h modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamdbf.cpp modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/plgdbsem.h modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfix.cpp modified: storage/connect/tabfix.h modified: storage/connect/tabfmt.cpp modified: storage/connect/tabfmt.h modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/table.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabmysql.h modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabpivot.h modified: storage/connect/tabsys.cpp modified: storage/connect/tabsys.h modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabutil.h modified: storage/connect/tabvct.cpp modified: storage/connect/tabvct.h modified: storage/connect/tabvir.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxcl.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h modified: storage/connect/xobject.h modified: storage/connect/xtable.h added: storage/connect/tabext.cpp added: storage/connect/tabext.h
1 parent 9fa0d2f commit 5c2c68d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2129
-1455
lines changed

storage/connect/array.cpp

Lines changed: 54 additions & 54 deletions
Large diffs are not rendered by default.

storage/connect/array.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**************** Array H Declares Source Code File (.H) ***************/
22
/* Name: ARRAY.H Version 3.1 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
4+
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
55
/* */
66
/* This file contains the ARRAY and VALBASE derived classes declares. */
77
/***********************************************************************/
@@ -53,8 +53,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
5353
using XOBJECT::GetIntValue;
5454
virtual void Reset(void) {Bot = -1;}
5555
virtual int Qcompare(int *, int *);
56-
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
57-
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;}
56+
virtual bool Compare(PXOB) {assert(false); return false;}
57+
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
5858
//virtual int CheckSpcCol(PTDB, int) {return 0;}
5959
virtual void Print(PGLOBAL g, FILE *f, uint n);
6060
virtual void Print(PGLOBAL g, char *ps, uint z);

storage/connect/colblk.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/************* Colblk C++ Functions Source Code File (.CPP) ************/
2-
/* Name: COLBLK.CPP Version 2.1 */
2+
/* Name: COLBLK.CPP Version 2.2 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
4+
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
55
/* */
66
/* This file contains the COLBLK class functions. */
77
/***********************************************************************/
@@ -300,7 +300,7 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
300300
#if defined(__WIN__)
301301
Format.Prec = 1; // Case insensitive
302302
#endif // __WIN__
303-
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
303+
Constant = (!To_Tdb->GetDef()->GetMultiple() &&
304304
To_Tdb->GetAmType() != TYPE_AM_PLG &&
305305
To_Tdb->GetAmType() != TYPE_AM_PLM);
306306
Fn = NULL;
@@ -312,11 +312,11 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
312312
/***********************************************************************/
313313
void FIDBLK::ReadColumn(PGLOBAL g)
314314
{
315-
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) {
315+
if (Fn != To_Tdb->GetFile(g)) {
316316
char filename[_MAX_PATH];
317317

318-
Fn = ((PTDBASE)To_Tdb)->GetFile(g);
319-
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
318+
Fn = To_Tdb->GetFile(g);
319+
PlugSetPath(filename, Fn, To_Tdb->GetPath());
320320

321321
if (Op != OP_XX) {
322322
char buff[_MAX_PATH];
@@ -378,10 +378,8 @@ void PRTBLK::ReadColumn(PGLOBAL g)
378378
{
379379
if (Pname == NULL) {
380380
char *p;
381-
PTDBASE tdbp = (PTDBASE)To_Tdb;
382-
383-
Pname = tdbp->GetDef()->GetStringCatInfo(g, "partname", "?");
384381

382+
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
385383
p = strrchr(Pname, '#');
386384
Value->SetValue_psz((p) ? p + 1 : Pname);
387385
} // endif Pname

storage/connect/connect.cc

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
159159
bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
160160
{
161161
if (tp) {
162-
bool b = ((PTDBASE)tp)->GetFtype() == RECFM_NAF;
162+
bool b = (tp->GetFtype() == RECFM_NAF);
163163
PTDBDOS tdbp = b ? NULL : (PTDBDOS)tp;
164164

165165
info->data_file_length = (b) ? 0 : (ulonglong)tdbp->GetFileLength(g);
@@ -331,9 +331,9 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
331331
} // endfor colp
332332

333333
// Attach the updated columns list to the main table
334-
((PTDBASE)tdbp)->SetSetCols(utp->GetColumns());
334+
tdbp->SetSetCols(utp->GetColumns());
335335
} else if (tdbp && mode == MODE_INSERT)
336-
((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns());
336+
tdbp->SetSetCols(tdbp->GetColumns());
337337

338338
// Now do open the physical table
339339
if (trace)
@@ -342,7 +342,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
342342

343343
//tdbp->SetMode(mode);
344344

345-
if (del/* && ((PTDBASE)tdbp)->GetFtype() != RECFM_NAF*/) {
345+
if (del/* && (tdbp->GetFtype() != RECFM_NAF*/) {
346346
// To avoid erasing the table when doing a partial delete
347347
// make a fake Next
348348
// PDOSDEF ddp= new(g) DOSDEF;
@@ -435,7 +435,7 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
435435

436436
if (!tdbp)
437437
return RC_FX;
438-
else if (((PTDBASE)tdbp)->GetKindex()) {
438+
else if (tdbp->GetKindex()) {
439439
// Reading sequencially an indexed table. This happens after the
440440
// handler function records_in_range was called and MySQL decides
441441
// to quit using the index (!!!) Drop the index.
@@ -482,7 +482,7 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
482482
{
483483
RCODE rc;
484484
PCOL colp;
485-
PTDBASE tp= (PTDBASE)tdbp;
485+
//PTDBASE tp= (PTDBASE)tdbp;
486486

487487
if (!tdbp)
488488
return RC_FX;
@@ -500,13 +500,13 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
500500
} // endif rc
501501

502502
// Store column values in table write buffer(s)
503-
for (colp= tp->GetSetCols(); colp; colp= colp->GetNext())
503+
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
504504
if (!colp->GetColUse(U_VIRTUAL))
505505
colp->WriteColumn(g);
506506

507-
if (tp->IsIndexed())
507+
if (tdbp->IsIndexed())
508508
// Index values must be sorted before updating
509-
rc= (RCODE)((PTDBDOS)tp)->GetTxfp()->StoreValues(g, true);
509+
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
510510
else
511511
// Return result code from write operation
512512
rc= (RCODE)tdbp->WriteDB(g);
@@ -534,24 +534,24 @@ RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp)
534534
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
535535
{
536536
RCODE rc;
537-
PTDBASE tp= (PTDBASE)tdbp;
537+
//PTDBASE tp= (PTDBASE)tdbp;
538538

539539
if (!tdbp || tdbp->GetMode() != MODE_DELETE)
540540
return RC_FX;
541541
else if (tdbp->IsReadOnly())
542542
return RC_NF;
543543

544544
if (all) {
545-
if (((PTDBASE)tdbp)->GetDef()->Indexable())
545+
if (tdbp->GetDef()->Indexable())
546546
((PTDBDOS)tdbp)->Cardinal= 0;
547547

548548
// Note: if all, this call will be done when closing the table
549549
rc= (RCODE)tdbp->DeleteDB(g, RC_FX);
550-
//} else if (tp->GetKindex() && !tp->GetKindex()->IsSorted() &&
551-
// tp->Txfp->GetAmType() != TYPE_AM_DBF) {
552-
} else if(tp->IsIndexed()) {
550+
//} else if (tdbp->GetKindex() && !((PTDBASE)tdbp)->GetKindex()->IsSorted() &&
551+
// ((PTDBASE)tdbp)->Txfp->GetAmType() != TYPE_AM_DBF) {
552+
} else if(tdbp->IsIndexed()) {
553553
// Index values must be sorted before updating
554-
rc= (RCODE)((PTDBDOS)tp)->GetTxfp()->StoreValues(g, false);
554+
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, false);
555555
} else // Return result code from delete operation
556556
rc= (RCODE)tdbp->DeleteDB(g, RC_OK);
557557

@@ -564,7 +564,7 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
564564
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
565565
{
566566
int rc= RC_OK;
567-
TDBASE *tbxp= (PTDBASE)tdbp;
567+
//TDBASE *tbxp= (PTDBASE)tdbp;
568568

569569
if (!tdbp)
570570
return rc; // Nothing to do
@@ -580,21 +580,21 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
580580
tdbp, tdbp->GetMode(), nox, abort);
581581

582582
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
583-
if (tbxp->IsIndexed())
583+
if (tdbp->IsIndexed())
584584
rc= ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
585585

586586
if (!rc)
587587
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
588588

589-
} else if (tbxp->GetMode() == MODE_UPDATE && tbxp->IsIndexed())
589+
} else if (tdbp->GetMode() == MODE_UPDATE && tdbp->IsIndexed())
590590
rc= ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
591591

592592
switch(rc) {
593593
case RC_FX:
594594
abort= true;
595595
break;
596596
case RC_INFO:
597-
PushWarning(g, tbxp);
597+
PushWarning(g, tdbp);
598598
break;
599599
} // endswitch rc
600600

@@ -630,11 +630,13 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
630630
if (trace > 1)
631631
printf("About to reset opt\n");
632632

633-
// Make all the eventual indexes
634-
tbxp= (TDBDOX*)tdbp;
635-
tbxp->ResetKindex(g, NULL);
636-
tbxp->SetKey_Col(NULL);
637-
rc= tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
633+
if (!tdbp->IsRemote()) {
634+
// Make all the eventual indexes
635+
PTDBDOX tbxp = (PTDBDOX)tdbp;
636+
tbxp->ResetKindex(g, NULL);
637+
tbxp->SetKey_Col(NULL);
638+
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
639+
} // endif remote
638640

639641
err:
640642
if (trace > 1)
@@ -656,10 +658,10 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
656658

657659
if (!ptdb)
658660
return -1;
659-
else if (!((PTDBASE)ptdb)->GetDef()->Indexable()) {
661+
else if (!ptdb->GetDef()->Indexable()) {
660662
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
661663
return 0;
662-
} else if (((PTDBASE)ptdb)->GetDef()->Indexable() == 3) {
664+
} else if (ptdb->GetDef()->Indexable() == 3) {
663665
return 1;
664666
} else
665667
tdbp= (PTDBDOX)ptdb;
@@ -744,7 +746,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
744746
if (!ptdb)
745747
return RC_FX;
746748
else
747-
x= ((PTDBASE)ptdb)->GetDef()->Indexable();
749+
x= ptdb->GetDef()->Indexable();
748750

749751
if (!x) {
750752
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
@@ -874,7 +876,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
874876
if (!ptdb)
875877
return -1;
876878

877-
x= ((PTDBASE)ptdb)->GetDef()->Indexable();
879+
x= ptdb->GetDef()->Indexable();
878880

879881
if (!x) {
880882
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());

storage/connect/filamdbf.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* */
66
/* COPYRIGHT: */
77
/* ---------- */
8-
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
8+
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
99
/* */
1010
/* WHAT THIS PROGRAM DOES: */
1111
/* ----------------------- */
@@ -593,6 +593,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
593593

594594
if (Accept) {
595595
Lrecl = reclen;
596+
Blksize = Nrec * Lrecl;
596597
PushWarning(g, Tdbp);
597598
} else
598599
return true;
@@ -609,7 +610,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
609610
header->Filedate[1] = datm->tm_mon + 1;
610611
header->Filedate[2] = datm->tm_mday;
611612
header->SetHeadlen((ushort)hlen);
612-
header->SetReclen((ushort)reclen);
613+
header->SetReclen(reclen);
613614
descp = (DESCRIPTOR*)header;
614615

615616
// Currently only standard Xbase types are supported
@@ -675,6 +676,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
675676

676677
if (Accept) {
677678
Lrecl = header.Reclen();
679+
Blksize = Nrec * Lrecl;
678680
PushWarning(g, Tdbp);
679681
} else
680682
return true;
@@ -967,6 +969,7 @@ int DBMFAM::Cardinality(PGLOBAL g)
967969

968970
if (Accept) {
969971
Lrecl = rln;
972+
Blksize = Nrec * Lrecl;
970973
PushWarning(g, Tdbp);
971974
} else
972975
return -1;
@@ -1019,6 +1022,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
10191022

10201023
if (Accept) {
10211024
Lrecl = hp->Reclen();
1025+
Blksize = Nrec * Lrecl;
10221026
PushWarning(g, Tdbp);
10231027
} else
10241028
return true;

0 commit comments

Comments
 (0)