/ SetBuffer: prepare a column block for write operation. */ /
| 399 | /* SetBuffer: prepare a column block for write operation. */ |
| 400 | /***********************************************************************/ |
| 401 | bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) |
| 402 | { |
| 403 | if (!(To_Val = value)) { |
| 404 | snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name); |
| 405 | return true; |
| 406 | } else if (Buf_Type == value->GetType()) { |
| 407 | // Values are of the (good) column type |
| 408 | if (Buf_Type == TYPE_DATE) { |
| 409 | // If any of the date values is formatted |
| 410 | // output format must be set for the receiving table |
| 411 | if (GetDomain() || ((DTVAL *)value)->IsFormatted()) |
| 412 | goto newval; // This will make a new value; |
| 413 | |
| 414 | } else if (Buf_Type == TYPE_DOUBLE || Buf_Type == TYPE_DECIM) |
| 415 | // Float values must be written with the correct (column) precision |
| 416 | // Note: maybe this should be forced by ShowValue instead of this ? |
| 417 | value->SetPrec(GetScale()); |
| 418 | |
| 419 | Value = value; // Directly access the external value |
| 420 | } else { |
| 421 | // Values are not of the (good) column type |
| 422 | if (check) { |
| 423 | snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name, |
| 424 | GetTypeName(Buf_Type), GetTypeName(value->GetType())); |
| 425 | return true; |
| 426 | } // endif check |
| 427 | |
| 428 | newval: |
| 429 | if (InitValue(g)) // Allocate the matching value block |
| 430 | return true; |
| 431 | |
| 432 | } // endif's Value, Buf_Type |
| 433 | |
| 434 | // Allocate the internal value buffer |
| 435 | AllocBuf(g); |
| 436 | |
| 437 | // Because Colblk's have been made from a copy of the original TDB in |
| 438 | // case of Update, we must reset them to point to the original one. |
| 439 | if (To_Tdb->GetOrig()) |
| 440 | To_Tdb = (PTDB)To_Tdb->GetOrig(); |
| 441 | |
| 442 | // Set the Column |
| 443 | Status = (ok) ? BUF_EMPTY : BUF_NO; |
| 444 | return false; |
| 445 | } // end of SetBuffer |
| 446 | |
| 447 | /***********************************************************************/ |
| 448 | /* ReadColumn: what this routine does is to access the key buffer set */ |
nothing calls this directly
no test coverage detected