/ Calculate the block sizes so block I/O can be used and also the */ Min/Max values for clustered/sorted table columns. */ /
| 640 | /* Min/Max values for clustered/sorted table columns. */ |
| 641 | /***********************************************************************/ |
| 642 | int 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)); |
nothing calls this directly
no test coverage detected