MCPcopy Create free account
hub / github.com/erans/pgsqlite / handle_integer_value

Method handle_integer_value

src/protocol/value_handler.rs:188–219  ·  view source on GitHub ↗

Handle integer values

(
        &self,
        int_val: i64,
        pg_type_oid: i32,
        binary_format: bool,
    )

Source from the content-addressed store, hash-verified

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(

Callers 2

convert_valueMethod · 0.80
handle_text_valueMethod · 0.80

Calls 2

to_oidMethod · 0.80

Tested by

no test coverage detected