MCPcopy Create free account
hub / github.com/MariaDB/server / MakeBlockValues

Method MakeBlockValues

storage/connect/tabdos.cpp:642–893  ·  view source on GitHub ↗

/ Calculate the block sizes so block I/O can be used and also the */ Min/Max values for clustered/sorted table columns. */ /

Source from the content-addressed store, hash-verified

640/* Min/Max values for clustered/sorted table columns. */
641/***********************************************************************/
642int TDBDOS::MakeBlockValues(PGLOBAL g)
643 {
644 int i, lg, nrec, rc, n = 0;
645 int curnum, curblk, block, savndv, savnbm;
646 void *savmin, *savmax;
647 bool blocked, xdb2 = false;
648//POOLHEADER save;
649 PCOLDEF cdp;
650 PDOSDEF defp = (PDOSDEF)To_Def;
651 PDOSCOL colp = NULL;
652 PDBUSER dup = PlgGetUser(g);
653//void *memp = cat->GetDescp();
654 (void) defp->GetCat(); // XXX Should be removed?
655
656
657 if ((nrec = defp->GetElemt()) < 2) {
658 if (!To_Def->Partitioned()) {
659 // This may be wrong to do in some cases
660 safe_strcpy(g->Message, sizeof(g->Message), MSG(TABLE_NOT_OPT));
661 return RC_INFO; // Not to be optimized
662 } else
663 return RC_OK;
664
665 } else if (GetMaxSize(g) == 0 || !(dup->Check & CHK_OPT)) {
666 // Suppress the opt file firstly if the table is void,
667 // secondly when it was modified with OPTIMIZATION unchecked
668 // because it is no more valid.
669 defp->RemoveOptValues(g); // Erase opt file
670 return RC_OK; // void table
671 } else if (MaxSize < 0)
672 return RC_FX;
673
674 defp->SetOptimized(0);
675
676 // Estimate the number of needed blocks
677 if ((block = (int)((MaxSize + (int)nrec - 1) / (int)nrec)) < 2) {
678 // This may be wrong to do in some cases
679 defp->RemoveOptValues(g);
680 safe_strcpy(g->Message, sizeof(g->Message), MSG(TABLE_NOT_OPT));
681 return RC_INFO; // Not to be optimized
682 } // endif block
683
684 // We have to use local variables because Txfp->CurBlk is set
685 // to Rows+1 by unblocked variable length table access methods.
686 curblk = -1;
687 curnum = nrec - 1;
688//last = 0;
689 Txfp->Block = block; // This is useful mainly for
690 Txfp->CurBlk = curblk; // blocked tables (ZLBFAM), for
691 Txfp->CurNum = curnum; // others it is just to be clean.
692
693 /*********************************************************************/
694 /* Allocate the array of block starting positions. */
695 /*********************************************************************/
696//if (memp)
697// save = *(PPOOLHEADER)memp;
698
699 Txfp->BlkPos = (int*)PlugSubAlloc(g, NULL, (block + 1) * sizeof(int));

Callers

nothing calls this directly

Calls 15

PlgGetUserFunction · 0.85
safe_strcpyFunction · 0.85
PlugSubAllocFunction · 0.85
IsTypeCharFunction · 0.85
GetProgMaxFunction · 0.85
GetCatMethod · 0.80
PartitionedMethod · 0.80
RemoveOptValuesMethod · 0.80
InitValueMethod · 0.80
SetMinMethod · 0.80
SetMaxMethod · 0.80
SetBitMapMethod · 0.80

Tested by

no test coverage detected