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

Method ReadColumn

storage/connect/tabdos.cpp:2538–2637  ·  view source on GitHub ↗

/ ReadColumn: what this routine does is to access the last line */ read from the corresponding table, extract from it the field */ corresponding to this column and convert it to buffer type. */ /

Source from the content-addressed store, hash-verified

2536/* corresponding to this column and convert it to buffer type. */
2537/***********************************************************************/
2538void DOSCOL::ReadColumn(PGLOBAL g)
2539 {
2540 char *p = NULL;
2541 int i, rc;
2542 int field;
2543 bool err = false;
2544 double dval;
2545 PTDBDOS tdbp = (PTDBDOS)To_Tdb;
2546
2547 if (trace(2))
2548 htrc(
2549 "DOS ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
2550 Name, tdbp->GetTdb_No(), ColUse, Status, Buf_Type);
2551
2552 /*********************************************************************/
2553 /* If physical reading of the line was deferred, do it now. */
2554 /*********************************************************************/
2555 if (!tdbp->IsRead())
2556 if ((rc = tdbp->ReadBuffer(g)) != RC_OK) {
2557 if (rc == RC_EF)
2558 snprintf(g->Message, sizeof(g->Message), MSG(INV_DEF_READ), rc);
2559
2560 throw 11;
2561 } // endif
2562
2563 p = tdbp->To_Line + Deplac;
2564 field = Long;
2565
2566 /*********************************************************************/
2567 /* For a variable length file, check if the field exists. */
2568 /*********************************************************************/
2569 if ((tdbp->Ftype == RECFM_VAR || tdbp->Ftype == RECFM_CSV)
2570 && strlen(tdbp->To_Line) < (unsigned)Deplac)
2571 field = 0;
2572 else if (Dsp)
2573 for(i = 0; i < field; i++)
2574 if (p[i] == Dsp)
2575 p[i] = '.';
2576
2577 switch (tdbp->Ftype) {
2578 case RECFM_VAR:
2579 case RECFM_FIX: // Fixed length text file
2580 case RECFM_CSV: // Variable length CSV or FMT file
2581 case RECFM_DBF: // Fixed length DBase file
2582 if (Nod) switch (Buf_Type) {
2583 case TYPE_INT:
2584 case TYPE_SHORT:
2585 case TYPE_TINY:
2586 case TYPE_BIGINT:
2587 err = Value->SetValue_char(p, field - Dcm);
2588 break;
2589 case TYPE_DOUBLE:
2590 if (!(err = Value->SetValue_char(p, field))) {
2591 dval = Value->GetFloatValue();
2592
2593 for (i = 0; i < Dcm; i++)
2594 dval /= 10.0;
2595

Callers

nothing calls this directly

Calls 10

PushWarningFunction · 0.85
SetValue_charMethod · 0.80
IsZeroMethod · 0.80
htrcFunction · 0.70
ReadBufferMethod · 0.45
GetFloatValueMethod · 0.45
SetValueMethod · 0.45
GetCharValueMethod · 0.45
RowNumberMethod · 0.45
SetNullMethod · 0.45

Tested by

no test coverage detected