Helper function to parse space-separated special datum format: "magic table_id row_id column_id"
| 379 | |
| 380 | // Helper function to parse space-separated special datum format: "magic table_id row_id column_id" |
| 381 | inline parsed_special_datum_result parse_space_separated_values(const char* data, size_t len) |
| 382 | { |
| 383 | parsed_special_datum_result result; |
| 384 | |
| 385 | // Parse space-separated values using std::from_chars for performance |
| 386 | const char* ptr = data; |
| 387 | const char* end = data + len; |
| 388 | |
| 389 | // Parse magic number |
| 390 | int32_t magic = 0; |
| 391 | auto [p1, ec1] = std::from_chars(ptr, end, magic); |
| 392 | if (ec1 != std::errc{} || magic != g_not_fetched_magic) { |
| 393 | return result; |
| 394 | } |
| 395 | |
| 396 | // Skip space |
| 397 | if (p1 >= end || *p1 != ' ') |
| 398 | return result; |
| 399 | ptr = p1 + 1; |
| 400 | |
| 401 | // Parse table_id |
| 402 | uint32_t table_id = 0; |
| 403 | auto [p2, ec2] = std::from_chars(ptr, end, table_id); |
| 404 | if (ec2 != std::errc{}) |
| 405 | return result; |
| 406 | |
| 407 | // Skip space |
| 408 | if (p2 >= end || *p2 != ' ') |
| 409 | return result; |
| 410 | ptr = p2 + 1; |
| 411 | |
| 412 | // Parse row_id |
| 413 | int64_t row_id = 0; |
| 414 | auto [p3, ec3] = std::from_chars(ptr, end, row_id); |
| 415 | if (ec3 != std::errc{}) |
| 416 | return result; |
| 417 | |
| 418 | // Skip space |
| 419 | if (p3 >= end || *p3 != ' ') |
| 420 | return result; |
| 421 | ptr = p3 + 1; |
| 422 | |
| 423 | // Parse column_id |
| 424 | int32_t column_id = 0; |
| 425 | auto [p4, ec4] = std::from_chars(ptr, end, column_id); |
| 426 | if (ec4 != std::errc{}) |
| 427 | return result; |
| 428 | |
| 429 | result.is_valid = true; |
| 430 | result.table_id = table_id; |
| 431 | result.row_id = row_id; |
| 432 | result.column_id = static_cast<AttrNumber>(column_id); |
| 433 | |
| 434 | return result; |
| 435 | } |
| 436 | |
| 437 | // Helper function to parse a single bytea element as a number |
| 438 | template <typename T> |
no outgoing calls
no test coverage detected