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

Method OpenTableFile

storage/connect/filamvct.cpp:414–495  ·  view source on GitHub ↗

/ VCT Access Method opening routine. */ New method now that this routine is called recursively (last table */ first in reverse order): index blocks are immediately linked to */ join block of next table if it exists or else are discarted. */ /

Source from the content-addressed store, hash-verified

412/* join block of next table if it exists or else are discarted. */
413/***********************************************************************/
414bool VCTFAM::OpenTableFile(PGLOBAL g)
415 {
416 char opmode[4], filename[_MAX_PATH];
417 MODE mode = Tdbp->GetMode();
418 PDBUSER dbuserp = PlgGetUser(g);
419
420 /*********************************************************************/
421 /* Update block info if necessary. */
422 /*********************************************************************/
423 if (Block < 0)
424 if ((Headlen = GetBlockInfo(g)) < 0)
425 return true;
426
427 /*********************************************************************/
428 /* Open according to input/output mode required. */
429 /*********************************************************************/
430 switch (mode) {
431 case MODE_READ:
432 snprintf(opmode, sizeof(opmode), "rb");
433 break;
434 case MODE_DELETE:
435 if (!Tdbp->GetNext()) {
436 // Store the number of deleted lines
437 DelRows = Cardinality(g);
438
439 // This will delete the whole file
440 snprintf(opmode, sizeof(opmode), "wb");
441 break;
442 } // endif
443
444 // Selective delete, pass thru
445 /* fall through */
446 case MODE_UPDATE:
447 UseTemp = Tdbp->IsUsingTemp(g);
448 snprintf(opmode, sizeof(opmode), (UseTemp) ? "rb" : "r+b");
449 break;
450 case MODE_INSERT:
451 if (MaxBlk) {
452 if (!Block)
453 if (MakeEmptyFile(g, To_File))
454 return true;
455
456 snprintf(opmode, sizeof(opmode), "r+b"); // Required to update empty blocks
457 } else if (!Block || Last == Nrec)
458 snprintf(opmode, sizeof(opmode), "ab");
459 else
460 snprintf(opmode, sizeof(opmode), "r+b"); // Required to update the last block
461
462 break;
463 default:
464 snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
465 return true;
466 } // endswitch Mode
467
468 /*********************************************************************/
469 /* Use conventionnal input/output functions. */
470 /*********************************************************************/
471 PlugSetPath(filename, To_File, Tdbp->GetPath());

Callers

nothing calls this directly

Calls 15

PlgGetUserFunction · 0.85
PlugOpenFileFunction · 0.85
PushWarningFunction · 0.85
CreateFileMapFunction · 0.85
GetLastErrorFunction · 0.85
CloseFileHandleFunction · 0.85
PlugSubAllocFunction · 0.85
PlugDupFunction · 0.85
safe_strcatFunction · 0.85
MakeFnPatternMethod · 0.80
IsSpecialMethod · 0.80
CardinalityFunction · 0.70

Tested by

no test coverage detected