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

Method OpenTableFile

storage/connect/filamfix.cpp:814–970  ·  view source on GitHub ↗

/ OpenTableFile: opens a huge file using Windows/Unix API's. */ /

Source from the content-addressed store, hash-verified

812/* OpenTableFile: opens a huge file using Windows/Unix API's. */
813/***********************************************************************/
814bool BGXFAM::OpenTableFile(PGLOBAL g)
815 {
816 char filename[_MAX_PATH];
817 MODE mode = Tdbp->GetMode();
818 PDBUSER dbuserp = PlgGetUser(g);
819
820 if ((To_Fb && To_Fb->Count) || Hfile != INVALID_HANDLE_VALUE) {
821 snprintf(g->Message, sizeof(g->Message), MSG(FILE_OPEN_YET), To_File);
822 return true;
823 } // endif
824
825 PlugSetPath(filename, To_File, Tdbp->GetPath());
826
827 if (trace(1))
828 htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
829
830#if defined(_WIN32)
831 DWORD rc, access, creation, share = 0;
832
833 /*********************************************************************/
834 /* Create the file object according to access mode */
835 /*********************************************************************/
836 switch (mode) {
837 case MODE_READ:
838 access = GENERIC_READ;
839 share = FILE_SHARE_READ;
840 creation = OPEN_EXISTING;
841 break;
842 case MODE_DELETE:
843 if (!Tdbp->GetNext()) {
844 // Store the number of deleted rows
845 DelRows = Cardinality(g);
846
847 // This will delete the whole file and provoque ReadDB to
848 // return immediately.
849 access = GENERIC_READ | GENERIC_WRITE;
850 creation = TRUNCATE_EXISTING;
851 Tdbp->ResetSize();
852 Headlen = 0;
853 break;
854 } // endif
855
856 // Selective delete, pass thru
857 case MODE_UPDATE:
858 if ((UseTemp = Tdbp->IsUsingTemp(g)))
859 access = GENERIC_READ;
860 else
861 access = GENERIC_READ | GENERIC_WRITE;
862
863 creation = OPEN_EXISTING;
864 break;
865 case MODE_INSERT:
866 access = GENERIC_WRITE;
867 creation = OPEN_ALWAYS;
868 break;
869 default:
870 snprintf(g->Message, sizeof(g->Message), MSG(BAD_OPEN_MODE), mode);
871 return true;

Callers

nothing calls this directly

Calls 13

PlgGetUserFunction · 0.85
GetLastErrorFunction · 0.85
global_openFunction · 0.85
PlugSubAllocFunction · 0.85
PushWarningFunction · 0.85
PlugSetPathFunction · 0.70
htrcFunction · 0.70
CardinalityFunction · 0.70
AllocateBufferFunction · 0.70
GetPathMethod · 0.45
GetNextMethod · 0.45
ResetSizeMethod · 0.45

Tested by

no test coverage detected