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

Method GetStringOption

storage/connect/ha_connect.cc:1389–1450  ·  view source on GitHub ↗

/ Return the value of a string option or sdef if not specified. */ /

Source from the content-addressed store, hash-verified

1387/* Return the value of a string option or sdef if not specified. */
1388/****************************************************************************/
1389PCSZ ha_connect::GetStringOption(PCSZ opname, PCSZ sdef)
1390{
1391 PCSZ opval= NULL;
1392 PTOS options= GetTableOptionStruct();
1393
1394 if (!stricmp(opname, "Connect")) {
1395 const char *cnc= options->connect;
1396
1397 if (cnc && *cnc)
1398 opval= cnc;
1399 else
1400 opval= GetListOption(xp->g, opname, options->oplist);
1401
1402 } else if (!stricmp(opname, "Query_String")) {
1403// This escapes everything and returns a wrong query
1404// opval= thd_query_string(table->in_use)->str;
1405 opval= (PCSZ)PlugSubAlloc(xp->g, NULL,
1406 thd_query_string(table->in_use)->length + 1);
1407 strcpy((char*)opval, thd_query_string(table->in_use)->str);
1408// sprintf((char*)opval, "%s", thd_query_string(table->in_use)->str);
1409 } else if (!stricmp(opname, "Partname"))
1410 opval= partname;
1411 else if (!stricmp(opname, "Table_charset")) {
1412 const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
1413 : table->s->table_charset;
1414
1415 if (chif)
1416 opval= (char*)chif->cs_name.str;
1417
1418 } else
1419 opval= GetStringTableOption(xp->g, options, opname, NULL);
1420
1421 if (opval && (!stricmp(opname, "connect")
1422 || !stricmp(opname, "tabname")
1423 || !stricmp(opname, "filename")
1424 || !stricmp(opname, "optname")
1425 || !stricmp(opname, "entry")))
1426 opval= GetRealString(opval);
1427
1428 if (!opval) {
1429 if (sdef && !strcmp(sdef, "*")) {
1430 // Return the handler default value
1431 if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database"))
1432 opval= (char*)GetDBName(NULL); // Current database
1433 else if (!stricmp(opname, "Type")) // Default type
1434 opval= (!options) ? NULL :
1435 (options->srcdef) ? (char*)"MYSQL" :
1436 (options->tabname) ? (char*)"PROXY" : (char*)"DOS";
1437 else if (!stricmp(opname, "User")) // Connected user
1438 opval= (char *) "root";
1439 else if (!stricmp(opname, "Host")) // Connected user host
1440 opval= (char *) "localhost";
1441 else
1442 opval= sdef; // Caller default
1443
1444 } else
1445 opval= sdef; // Caller default
1446

Callers 4

MakeTableDescMethod · 0.80
GetSizeCatInfoMethod · 0.80
GetCharCatInfoMethod · 0.80
GetStringCatInfoMethod · 0.80

Calls 4

GetListOptionFunction · 0.85
PlugSubAllocFunction · 0.85
thd_query_stringFunction · 0.85
GetStringTableOptionFunction · 0.85

Tested by

no test coverage detected