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

Method ReadColumn

storage/connect/tabfmt.cpp:1445–1501  ·  view source on GitHub ↗

/ ReadColumn: call DOSCOL::ReadColumn after having set the offet */ and length of the field to read as calculated by TDBCSV::ReadDB. */ /

Source from the content-addressed store, hash-verified

1443/* and length of the field to read as calculated by TDBCSV::ReadDB. */
1444/***********************************************************************/
1445void CSVCOL::ReadColumn(PGLOBAL g)
1446 {
1447 int rc;
1448 PTDBCSV tdbp = (PTDBCSV)To_Tdb;
1449
1450 /*********************************************************************/
1451 /* If physical reading of the line was deferred, do it now. */
1452 /*********************************************************************/
1453 if (!tdbp->IsRead())
1454 if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
1455 if (rc == RC_EF)
1456 snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
1457
1458 throw 34;
1459 } // endif
1460
1461 if (tdbp->Mode != MODE_UPDATE) {
1462 int colen = Long; // Column length
1463
1464 // Set the field offset and length for this row
1465 Deplac = tdbp->Offset[Fldnum]; // Field offset
1466 Long = tdbp->Fldlen[Fldnum]; // Field length
1467
1468 if (trace(2))
1469 htrc("CSV ReadColumn %s Fldnum=%d offset=%d fldlen=%d\n",
1470 Name, Fldnum, Deplac, Long);
1471
1472 if (Long > colen && tdbp->CheckErr()) {
1473 Long = colen; // Restore column length
1474 snprintf(g->Message, sizeof(g->Message), MSG(FLD_TOO_LNG_FOR),
1475 Fldnum + 1, Name, To_Tdb->RowNumber(g), tdbp->GetFile(g));
1476 throw 34;
1477 } // endif Long
1478
1479 // Now do the reading
1480 DOSCOL::ReadColumn(g);
1481
1482 // Restore column length
1483 Long = colen;
1484 } else { // Mode Update
1485 // Field have been copied in TDB Field array
1486 PSZ fp = tdbp->Field[Fldnum];
1487
1488 if (Dsp)
1489 for (int i = 0; fp[i]; i++)
1490 if (fp[i] == Dsp)
1491 fp[i] = '.';
1492
1493 Value->SetValue_psz(fp);
1494
1495 // Set null when applicable
1496 if (Nullable)
1497 Value->SetNull(Value->IsZero());
1498
1499 } // endif Mode
1500
1501 } // end of ReadColumn
1502

Callers

nothing calls this directly

Calls 8

CheckErrMethod · 0.80
SetValue_pszMethod · 0.80
IsZeroMethod · 0.80
htrcFunction · 0.70
ReadBufferMethod · 0.45
RowNumberMethod · 0.45
GetFileMethod · 0.45
SetNullMethod · 0.45

Tested by

no test coverage detected