(
CopyTextFormatParams { null, delimiter }: &CopyTextFormatParams,
row: &RowRef,
typ: &SqlRelationType,
out: &mut Vec<u8>,
)
| 67 | } |
| 68 | |
| 69 | fn encode_copy_row_text( |
| 70 | CopyTextFormatParams { null, delimiter }: &CopyTextFormatParams, |
| 71 | row: &RowRef, |
| 72 | typ: &SqlRelationType, |
| 73 | out: &mut Vec<u8>, |
| 74 | ) -> Result<(), io::Error> { |
| 75 | let null = null.as_bytes(); |
| 76 | let mut buf = BytesMut::new(); |
| 77 | for (idx, field) in mz_pgrepr::values_from_row(row, typ).into_iter().enumerate() { |
| 78 | if idx > 0 { |
| 79 | out.push(*delimiter); |
| 80 | } |
| 81 | match field { |
| 82 | None => out.extend(null), |
| 83 | Some(field) => { |
| 84 | buf.clear(); |
| 85 | field.encode_text(&mut buf); |
| 86 | for b in &buf { |
| 87 | match b { |
| 88 | b'\\' => out.extend(b"\\\\"), |
| 89 | b'\n' => out.extend(b"\\n"), |
| 90 | b'\r' => out.extend(b"\\r"), |
| 91 | b'\t' => out.extend(b"\\t"), |
| 92 | _ => out.push(*b), |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | out.push(b'\n'); |
| 99 | Ok(()) |
| 100 | } |
| 101 | |
| 102 | fn encode_copy_row_csv( |
| 103 | CopyCsvFormatParams { |
no test coverage detected