Handle integer values
(
&self,
int_val: i64,
pg_type_oid: i32,
binary_format: bool,
)
| 186 | |
| 187 | /// Handle integer values |
| 188 | fn handle_integer_value( |
| 189 | &self, |
| 190 | int_val: i64, |
| 191 | pg_type_oid: i32, |
| 192 | binary_format: bool, |
| 193 | ) -> io::Result<Option<MappedValue>> { |
| 194 | // Handle boolean type specially |
| 195 | if pg_type_oid == PgType::Bool.to_oid() { |
| 196 | if binary_format { |
| 197 | let pg_data = self.convert_integer_binary(int_val, pg_type_oid); |
| 198 | return Ok(Some(MappedValue::Memory(pg_data))); |
| 199 | } else { |
| 200 | // Use small value optimization for boolean text format |
| 201 | let small = crate::protocol::SmallValue::from_bool(int_val != 0); |
| 202 | return Ok(Some(MappedValue::Small(small))); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // Try to use small value optimization for text format |
| 207 | if !binary_format |
| 208 | && let Some(small) = crate::protocol::SmallValue::from_integer(int_val) { |
| 209 | return Ok(Some(MappedValue::Small(small))); |
| 210 | } |
| 211 | |
| 212 | let pg_data = if binary_format { |
| 213 | self.convert_integer_binary(int_val, pg_type_oid) |
| 214 | } else { |
| 215 | int_val.to_string().into_bytes() |
| 216 | }; |
| 217 | |
| 218 | Ok(Some(MappedValue::Memory(pg_data))) |
| 219 | } |
| 220 | |
| 221 | /// Handle floating-point values |
| 222 | fn handle_real_value( |
no test coverage detected