| 449 | } |
| 450 | |
| 451 | inline Datum make_special_datum(Oid table_id, int64_t row_id, AttrNumber column_id, Oid attr_typeid) |
| 452 | { |
| 453 | if (!can_make_special_datum(attr_typeid)) { |
| 454 | elog(ERROR, "Cannot create special datum for type %u", attr_typeid); |
| 455 | } |
| 456 | if (is_string_type(attr_typeid)) { |
| 457 | std::string str = fmt::format("{} {} {} {}", g_not_fetched_magic, table_id, row_id, column_id); |
| 458 | return PointerGetDatum(cstring_to_text_with_len(str.data(), static_cast<int>(str.size()))); |
| 459 | } else if (type_is_array(attr_typeid)) { |
| 460 | switch (attr_typeid) { |
| 461 | case INT2ARRAYOID: { |
| 462 | Datum* elements = (Datum*)palloc(8 * sizeof(Datum)); |
| 463 | elements[0] = Int16GetDatum(static_cast<int16_t>(g_not_fetched_magic & 0xFFFF)); |
| 464 | elements[1] = Int16GetDatum(static_cast<int16_t>((g_not_fetched_magic >> 16) & 0xFFFF)); |
| 465 | elements[2] = Int16GetDatum(static_cast<int16_t>(table_id & 0xFFFF)); |
| 466 | elements[3] = Int16GetDatum(static_cast<int16_t>((table_id >> 16) & 0xFFFF)); |
| 467 | elements[4] = Int16GetDatum(static_cast<int16_t>(row_id & 0xFFFF)); |
| 468 | elements[5] = Int16GetDatum(static_cast<int16_t>((row_id >> 16) & 0xFFFF)); |
| 469 | elements[6] = Int16GetDatum(static_cast<int16_t>((row_id >> 32) & 0xFFFF)); |
| 470 | elements[7] = Int16GetDatum(static_cast<int16_t>(column_id)); |
| 471 | return PointerGetDatum(construct_array(elements, 8, INT2OID, sizeof(int16_t), true, 'i')); |
| 472 | } |
| 473 | case INT4ARRAYOID: { |
| 474 | Datum* elements = (Datum*)palloc(4 * sizeof(Datum)); |
| 475 | elements[0] = Int32GetDatum(g_not_fetched_magic); |
| 476 | elements[1] = Int32GetDatum(static_cast<int32_t>(table_id)); |
| 477 | elements[2] = Int64GetDatum(row_id); |
| 478 | elements[3] = Int32GetDatum(static_cast<int32_t>(column_id)); |
| 479 | return PointerGetDatum(construct_array(elements, 4, INT4OID, sizeof(int32_t), true, 'i')); |
| 480 | } |
| 481 | case INT8ARRAYOID: { |
| 482 | Datum* elements = (Datum*)palloc(4 * sizeof(Datum)); |
| 483 | elements[0] = Int64GetDatum(static_cast<int64_t>(g_not_fetched_magic)); |
| 484 | elements[1] = Int64GetDatum(static_cast<int64_t>(table_id)); |
| 485 | elements[2] = Int64GetDatum(static_cast<int64_t>(row_id)); |
| 486 | elements[3] = Int64GetDatum(static_cast<int64_t>(column_id)); |
| 487 | return PointerGetDatum(construct_array(elements, 4, INT8OID, sizeof(int64_t), true, 'd')); |
| 488 | } |
| 489 | case FLOAT4ARRAYOID: { |
| 490 | Datum* elements = (Datum*)palloc(4 * sizeof(Datum)); |
| 491 | elements[0] = Float4GetDatum(static_cast<float>(g_not_fetched_magic)); |
| 492 | elements[1] = Float4GetDatum(static_cast<float>(table_id)); |
| 493 | elements[2] = Float4GetDatum(static_cast<float>(row_id)); |
| 494 | elements[3] = Float4GetDatum(static_cast<float>(column_id)); |
| 495 | return PointerGetDatum(construct_array(elements, 4, FLOAT4OID, sizeof(float), true, 'f')); |
| 496 | } |
| 497 | case FLOAT8ARRAYOID: { |
| 498 | Datum* elements = (Datum*)palloc(4 * sizeof(Datum)); |
| 499 | elements[0] = Float8GetDatum(static_cast<double>(g_not_fetched_magic)); |
| 500 | elements[1] = Float8GetDatum(static_cast<double>(table_id)); |
| 501 | elements[2] = Float8GetDatum(static_cast<double>(row_id)); |
| 502 | elements[3] = Float8GetDatum(static_cast<double>(column_id)); |
| 503 | return PointerGetDatum(construct_array(elements, 4, FLOAT8OID, sizeof(double), true, 'd')); |
| 504 | } |
| 505 | case BYTEAARRAYOID: { |
| 506 | // For BYTEA arrays, we create an array of bytea elements |
| 507 | Datum* elements = (Datum*)palloc(4 * sizeof(Datum)); |
| 508 |
no test coverage detected