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

Method OpenTableFile

storage/connect/filamtxt.cpp:546–621  ·  view source on GitHub ↗

/ OpenTableFile: Open a DOS/UNIX table file using C standard I/Os. */ /

Source from the content-addressed store, hash-verified

544/* OpenTableFile: Open a DOS/UNIX table file using C standard I/Os. */
545/***********************************************************************/
546bool DOSFAM::OpenTableFile(PGLOBAL g)
547 {
548 char opmode[4], filename[_MAX_PATH];
549//int ftype = Tdbp->GetFtype();
550 MODE mode = Tdbp->Mode;
551 PDBUSER dbuserp = PlgGetUser(g);
552
553 // This is required when using Unix files under Windows and vice versa
554//Bin = (Blocked || Ending != CRLF);
555 Bin = true; // To avoid ftell problems
556
557 switch (mode) {
558 case MODE_READ:
559 snprintf(opmode, sizeof(opmode), "r");
560 break;
561 case MODE_DELETE:
562 if (!Tdbp->Next) {
563 // Store the number of deleted lines
564 DelRows = Cardinality(g);
565
566 if (Blocked) {
567 // Cardinality must return 0
568 Block = 0;
569 Last = Nrec;
570 } // endif blocked
571
572 // This will erase the entire file
573 snprintf(opmode, sizeof(opmode), "w");
574 Tdbp->ResetSize();
575 break;
576 } // endif
577
578 // Selective delete, pass thru
579 Bin = true;
580 /* fall through */
581 case MODE_UPDATE:
582 if ((UseTemp = Tdbp->IsUsingTemp(g))) {
583 snprintf(opmode, sizeof(opmode), "r");
584 Bin = true;
585 } else
586 snprintf(opmode, sizeof(opmode), "r+");
587
588 break;
589 case MODE_INSERT:
590 snprintf(opmode, sizeof(opmode), "a+");
591 break;
592 default:
593 snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
594 return true;
595 } // endswitch Mode
596
597 // For blocked I/O or for moving lines, open the table in binary
598 safe_strcat(opmode, sizeof(opmode), (Bin) ? "b" : "t");
599
600 // Now open the file stream
601 PlugSetPath(filename, To_File, Tdbp->GetPath());
602
603 if (!(Stream = PlugOpenFile(g, filename, opmode))) {

Callers

nothing calls this directly

Calls 11

PlgGetUserFunction · 0.85
safe_strcatFunction · 0.85
PlugOpenFileFunction · 0.85
PushWarningFunction · 0.85
CardinalityFunction · 0.70
PlugSetPathFunction · 0.70
htrcFunction · 0.70
AllocateBufferFunction · 0.70
ResetSizeMethod · 0.45
IsUsingTempMethod · 0.45
GetPathMethod · 0.45

Tested by

no test coverage detected