(
buf: &mut B,
d: Datum<'a>,
ty: &SqlScalarType,
)
| 2534 | } |
| 2535 | |
| 2536 | fn stringify_datum<'a, B>( |
| 2537 | buf: &mut B, |
| 2538 | d: Datum<'a>, |
| 2539 | ty: &SqlScalarType, |
| 2540 | ) -> Result<strconv::Nestable, EvalError> |
| 2541 | where |
| 2542 | B: FormatBuffer, |
| 2543 | { |
| 2544 | use SqlScalarType::*; |
| 2545 | match &ty { |
| 2546 | AclItem => Ok(strconv::format_acl_item(buf, d.unwrap_acl_item())), |
| 2547 | Bool => Ok(strconv::format_bool(buf, d.unwrap_bool())), |
| 2548 | Int16 => Ok(strconv::format_int16(buf, d.unwrap_int16())), |
| 2549 | Int32 => Ok(strconv::format_int32(buf, d.unwrap_int32())), |
| 2550 | Int64 => Ok(strconv::format_int64(buf, d.unwrap_int64())), |
| 2551 | UInt16 => Ok(strconv::format_uint16(buf, d.unwrap_uint16())), |
| 2552 | UInt32 | Oid | RegClass | RegProc | RegType => { |
| 2553 | Ok(strconv::format_uint32(buf, d.unwrap_uint32())) |
| 2554 | } |
| 2555 | UInt64 => Ok(strconv::format_uint64(buf, d.unwrap_uint64())), |
| 2556 | Float32 => Ok(strconv::format_float32(buf, d.unwrap_float32())), |
| 2557 | Float64 => Ok(strconv::format_float64(buf, d.unwrap_float64())), |
| 2558 | Numeric { .. } => Ok(strconv::format_numeric(buf, &d.unwrap_numeric())), |
| 2559 | Date => Ok(strconv::format_date(buf, d.unwrap_date())), |
| 2560 | Time => Ok(strconv::format_time(buf, d.unwrap_time())), |
| 2561 | Timestamp { .. } => Ok(strconv::format_timestamp(buf, &d.unwrap_timestamp())), |
| 2562 | TimestampTz { .. } => Ok(strconv::format_timestamptz(buf, &d.unwrap_timestamptz())), |
| 2563 | Interval => Ok(strconv::format_interval(buf, d.unwrap_interval())), |
| 2564 | Bytes => Ok(strconv::format_bytes(buf, d.unwrap_bytes())), |
| 2565 | String | VarChar { .. } | PgLegacyName => Ok(strconv::format_string(buf, d.unwrap_str())), |
| 2566 | Char { length } => Ok(strconv::format_string( |
| 2567 | buf, |
| 2568 | &mz_repr::adt::char::format_str_pad(d.unwrap_str(), *length), |
| 2569 | )), |
| 2570 | PgLegacyChar => { |
| 2571 | format_pg_legacy_char(buf, d.unwrap_uint8())?; |
| 2572 | Ok(strconv::Nestable::MayNeedEscaping) |
| 2573 | } |
| 2574 | Jsonb => Ok(strconv::format_jsonb(buf, JsonbRef::from_datum(d))), |
| 2575 | Uuid => Ok(strconv::format_uuid(buf, d.unwrap_uuid())), |
| 2576 | Record { fields, .. } => { |
| 2577 | let mut fields = fields.iter(); |
| 2578 | strconv::format_record(buf, d.unwrap_list(), |buf, d| { |
| 2579 | let (_name, ty) = fields.next().unwrap(); |
| 2580 | if d.is_null() { |
| 2581 | Ok(buf.write_null()) |
| 2582 | } else { |
| 2583 | stringify_datum(buf.nonnull_buffer(), d, &ty.scalar_type) |
| 2584 | } |
| 2585 | }) |
| 2586 | } |
| 2587 | Array(elem_type) => strconv::format_array( |
| 2588 | buf, |
| 2589 | &d.unwrap_array().dims().into_iter().collect::<Vec<_>>(), |
| 2590 | d.unwrap_array().elements(), |
| 2591 | |buf, d| { |
| 2592 | if d.is_null() { |
| 2593 | Ok(buf.write_null()) |
no test coverage detected