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

Function OEMColumns

storage/connect/reldef.cpp:69–163  ·  view source on GitHub ↗

/ OEMColumns: Get table column info for an OEM table. */ /

Source from the content-addressed store, hash-verified

67/* OEMColumns: Get table column info for an OEM table. */
68/***********************************************************************/
69PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
70{
71 typedef PQRYRES(__stdcall* XCOLDEF) (PGLOBAL, void*, char*, char*, bool);
72 const char* module, * subtype;
73 char c, soname[_MAX_PATH], getname[40] = "Col";
74#if defined(_WIN32)
75 HANDLE hdll; /* Handle to the external DLL */
76#else // !_WIN32
77 void* hdll; /* Handle for the loaded shared library */
78#endif // !_WIN32
79 XCOLDEF coldef = NULL;
80 PQRYRES qrp = NULL;
81
82 module = topt->module;
83 subtype = topt->subtype;
84
85 if (!module || !subtype)
86 return NULL;
87
88 /*********************************************************************/
89 /* Ensure that the .dll doesn't have a path. */
90 /* This is done to ensure that only approved dll from the system */
91 /* directories are used (to make this even remotely secure). */
92 /*********************************************************************/
93 if (check_valid_path(module, strlen(module))) {
94 safe_strcpy(g->Message, sizeof(g->Message), "Module cannot contain a path");
95 return NULL;
96 }
97 else if (strlen(subtype)+1+3 >= sizeof(getname)) {
98 safe_strcpy(g->Message, sizeof(g->Message), "Subtype string too long");
99 return NULL;
100 }
101 else
102 PlugSetPath(soname, module, GetPluginDir());
103
104 // The exported name is always in uppercase
105 for (int i = 0; ; i++) {
106 c = subtype[i];
107 getname[i + 3] = toupper(c);
108 if (!c) break;
109 } // endfor i
110
111#if defined(_WIN32)
112 // Load the Dll implementing the table
113 if (!(hdll = LoadLibrary(soname))) {
114 char buf[256];
115 DWORD rc = GetLastError();
116
117 snprintf(g->Message, sizeof(g->Message), MSG(DLL_LOAD_ERROR), rc, soname);
118 FormatMessage(FORMAT_MESSAGE_FLAGS, NULL, rc, 0,
119 (LPTSTR)buf, sizeof(buf), NULL);
120 safe_strcat(g->Message, sizeof(g->Message), ": ");
121 safe_strcat(g->Message, sizeof(g->Message), buf);
122 return NULL;
123 } // endif hDll
124
125// Get the function returning an instance of the external DEF class
126 if (!(coldef = (XCOLDEF)GetProcAddress((HINSTANCE)hdll, getname))) {

Callers 1

Calls 7

check_valid_pathFunction · 0.85
safe_strcpyFunction · 0.85
GetPluginDirFunction · 0.85
GetLastErrorFunction · 0.85
safe_strcatFunction · 0.85
dlerrorFunction · 0.85
PlugSetPathFunction · 0.70

Tested by

no test coverage detected