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

Method OpenTableFile

storage/connect/filamdbf.cpp:578–637  ·  view source on GitHub ↗

/ OpenTableFile: Open a DBF table file using C standard I/Os. */ Binary mode cannot be used on Insert because of EOF (CTRL+Z) char. */ /

Source from the content-addressed store, hash-verified

576/* Binary mode cannot be used on Insert because of EOF (CTRL+Z) char. */
577/***********************************************************************/
578bool DBFFAM::OpenTableFile(PGLOBAL g)
579 {
580 char opmode[4], filename[_MAX_PATH];
581//int ftype = Tdbp->GetFtype();
582 MODE mode = Tdbp->GetMode();
583 PDBUSER dbuserp = PlgGetUser(g);
584
585 switch (mode) {
586 case MODE_READ:
587 strcpy(opmode, "rb");
588 break;
589 case MODE_DELETE:
590 if (!Tdbp->GetNext()) {
591 // Store the number of deleted lines
592 DelRows = -1; // Means all lines deleted
593// DelRows = Cardinality(g); no good because of soft deleted lines
594
595 // This will erase the entire file
596 strcpy(opmode, "w");
597 Tdbp->ResetSize();
598 Records = 0;
599 break;
600 } // endif
601
602 // Selective delete
603 /* fall through */
604 case MODE_UPDATE:
605 UseTemp = Tdbp->IsUsingTemp(g);
606 strcpy(opmode, (UseTemp) ? "rb" : "r+b");
607 break;
608 case MODE_INSERT:
609 strcpy(opmode, Records ? "r+b" : "w+b");
610 break;
611 default:
612 snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
613 return true;
614 } // endswitch Mode
615
616 // Now open the file stream
617 PlugSetPath(filename, To_File, Tdbp->GetPath());
618
619 if (!(Stream = PlugOpenFile(g, filename, opmode))) {
620 if (trace(1))
621 htrc("%s\n", g->Message);
622
623 return (mode == MODE_READ && errno == ENOENT)
624 ? PushWarning(g, Tdbp) : true;
625 } // endif Stream
626
627 if (trace(1))
628 htrc("File %s is open in mode %s\n", filename, opmode);
629
630 To_Fb = dbuserp->Openlist; // Keep track of File block
631
632 /*********************************************************************/
633 /* Allocate the line buffer. For mode Delete a bigger buffer has to */
634 /* be allocated because is it also used to move lines into the file.*/
635 /*********************************************************************/

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected