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

Method MapColumnFile

storage/connect/filamvct.cpp:2774–2881  ·  view source on GitHub ↗

/ Open the file corresponding to one column. */ /

Source from the content-addressed store, hash-verified

2772/* Open the file corresponding to one column. */
2773/***********************************************************************/
2774bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
2775 {
2776 char filename[_MAX_PATH];
2777 size_t len;
2778 HANDLE hFile;
2779 MEMMAP mm;
2780 PFBLOCK fp;
2781 PDBUSER dup = PlgGetUser(g);
2782
2783 snprintf(filename, _MAX_PATH, Colfn, i+1);
2784
2785 /*********************************************************************/
2786 /* The whole file will be mapped so we can use it as */
2787 /* if it were entirely read into virtual memory. */
2788 /* Firstly we check whether this file have been already mapped. */
2789 /*********************************************************************/
2790 if (mode == MODE_READ) {
2791 for (fp = dup->Openlist; fp; fp = fp->Next)
2792 if (fp->Type == TYPE_FB_MAP && !stricmp(fp->Fname, filename)
2793 && fp->Count && fp->Mode == mode)
2794 break;
2795
2796 if (trace(1))
2797 htrc("Mapping file, fp=%p\n", fp);
2798
2799 } else
2800 fp = NULL;
2801
2802 if (fp) {
2803 /*******************************************************************/
2804 /* File already mapped. Just increment use count and get pointer. */
2805 /*******************************************************************/
2806 fp->Count++;
2807 Memcol[i] = fp->Memory;
2808 len = fp->Length;
2809 } else {
2810 /*******************************************************************/
2811 /* Create the mapping file object. */
2812 /*******************************************************************/
2813 hFile = CreateFileMap(g, filename, &mm, mode, DelRows);
2814
2815 if (hFile == INVALID_HANDLE_VALUE) {
2816 DWORD rc = GetLastError();
2817
2818 if (!(*g->Message))
2819 snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
2820 "map", (int) rc, filename);
2821 if (trace(1))
2822 htrc("%s\n", g->Message);
2823
2824 return (mode == MODE_READ && rc == ENOENT)
2825 ? PushWarning(g, Tdbp) : true;
2826 } // endif hFile
2827
2828 /*****************************************************************/
2829 /* Get the file size (assuming file is smaller than 4 GB) */
2830 /*****************************************************************/
2831 len = (size_t)mm.lenL;

Callers

nothing calls this directly

Calls 8

PlgGetUserFunction · 0.85
CreateFileMapFunction · 0.85
GetLastErrorFunction · 0.85
PushWarningFunction · 0.85
CloseFileHandleFunction · 0.85
PlugSubAllocFunction · 0.85
PlugDupFunction · 0.85
htrcFunction · 0.70

Tested by

no test coverage detected