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

Method SetBuffer

storage/connect/tabdos.cpp:2484–2531  ·  view source on GitHub ↗

/ SetBuffer: prepare a column block for write operation. */ /

Source from the content-addressed store, hash-verified

2482/* SetBuffer: prepare a column block for write operation. */
2483/***********************************************************************/
2484bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
2485 {
2486 if (!(To_Val = value)) {
2487 snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name);
2488 return true;
2489 } else if (Buf_Type == value->GetType()) {
2490 // Values are of the (good) column type
2491 if (Buf_Type == TYPE_DATE) {
2492 // If any of the date values is formatted
2493 // output format must be set for the receiving table
2494 if (GetDomain() || ((DTVAL *)value)->IsFormatted())
2495 goto newval; // This will make a new value;
2496
2497 } else if (Buf_Type == TYPE_DOUBLE)
2498 // Float values must be written with the correct (column) precision
2499 // Note: maybe this should be forced by ShowValue instead of this ?
2500 value->SetPrec(GetScale());
2501
2502 Value = value; // Directly access the external value
2503 } else {
2504 // Values are not of the (good) column type
2505 if (check) {
2506 snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name,
2507 GetTypeName(Buf_Type), GetTypeName(value->GetType()));
2508 return true;
2509 } // endif check
2510
2511 newval:
2512 if (InitValue(g)) // Allocate the matching value block
2513 return true;
2514
2515 } // endif's Value, Buf_Type
2516
2517 // Allocate the buffer used in WriteColumn for numeric columns
2518 if (!Buf && IsTypeNum(Buf_Type))
2519 Buf = (char*)PlugSubAlloc(g, NULL, MY_MAX(64, Long + 1));
2520 else // Text columns do not need additional buffer
2521 Buf = (char*)Value->GetTo_Val();
2522
2523 // Because Colblk's have been made from a copy of the original TDB in
2524 // case of Update, we must reset them to point to the original one.
2525 if (To_Tdb->GetOrig())
2526 To_Tdb = (PTDB)To_Tdb->GetOrig();
2527
2528 // Set the Column
2529 Status = (ok) ? BUF_EMPTY : BUF_NO;
2530 return false;
2531 } // end of SetBuffer
2532
2533/***********************************************************************/
2534/* ReadColumn: what this routine does is to access the last line */

Callers 2

CntOpenTableFunction · 0.45
InitMethod · 0.45

Calls 8

GetDomainFunction · 0.85
GetTypeNameFunction · 0.85
PlugSubAllocFunction · 0.85
GetTo_ValMethod · 0.80
GetScaleFunction · 0.70
IsTypeNumFunction · 0.70
GetTypeMethod · 0.45
SetPrecMethod · 0.45

Tested by

no test coverage detected