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

Method OpenTableFile

storage/connect/filamap.cpp:102–787  ·  view source on GitHub ↗

/ OpenTableFile: Open a DOS/UNIX table file as a mapped file. */ /

Source from the content-addressed store, hash-verified

100/* OpenTableFile: Open a DOS/UNIX table file as a mapped file. */
101/***********************************************************************/
102bool MAPFAM::OpenTableFile(PGLOBAL g)
103 {
104 char filename[_MAX_PATH];
105 size_t len;
106 MODE mode = Tdbp->GetMode();
107 PFBLOCK fp;
108 PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr;
109
110#if defined(_DEBUG)
111 // Insert mode is no more handled using file mapping
112 assert(mode != MODE_INSERT);
113#endif // _DEBUG
114
115 /*********************************************************************/
116 /* We used the file name relative to recorded datapath. */
117 /*********************************************************************/
118 PlugSetPath(filename, To_File, Tdbp->GetPath());
119
120 /*********************************************************************/
121 /* Under Win32 the whole file will be mapped so we can use it as */
122 /* if it were entirely read into virtual memory. */
123 /* Firstly we check whether this file have been already mapped. */
124 /*********************************************************************/
125 if (mode == MODE_READ) {
126 for (fp = dbuserp->Openlist; fp; fp = fp->Next)
127 if (fp->Type == TYPE_FB_MAP && !stricmp(fp->Fname, filename)
128 && fp->Count && fp->Mode == mode)
129 break;
130
131 if (trace(1))
132 htrc("Mapping file, fp=%p\n", fp);
133
134 } else
135 fp = NULL;
136
137 if (fp) {
138 /*******************************************************************/
139 /* File already mapped. Just increment use count and get pointer. */
140 /*******************************************************************/
141 fp->Count++;
142 Memory = fp->Memory;
143 len = fp->Length;
144 } else {
145 /*******************************************************************/
146 /* If required, delete the whole file if no filtering is implied. */
147 /*******************************************************************/
148 bool del;
149 HANDLE hFile;
150 MEMMAP mm;
151
152 del = mode == MODE_DELETE && !Tdbp->GetNext();
153
154 if (del)
155 DelRows = Cardinality(g);
156
157 /*******************************************************************/
158 /* Create the mapping file object. */
159 /*******************************************************************/

Callers

nothing calls this directly

Calls 12

CreateFileMapFunction · 0.85
GetLastErrorFunction · 0.85
CloseFileHandleFunction · 0.85
PlugSubAllocFunction · 0.85
PlugDupFunction · 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