File tree 1 file changed +10
-1
lines changed
pgdog/src/net/messages/data_types
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::{
5
5
} ;
6
6
7
7
use bytes:: Buf ;
8
+ use tracing:: warn;
8
9
9
10
use crate :: net:: messages:: data_row:: Data ;
10
11
@@ -18,6 +19,9 @@ pub struct Numeric {
18
19
19
20
impl Hash for Numeric {
20
21
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
22
+ if self . data . is_nan ( ) {
23
+ warn ! ( "using NaNs in hashing, this breaks aggregates" ) ;
24
+ }
21
25
// We don't expect NaNs from Postgres.
22
26
self . data . to_bits ( ) . hash ( state) ;
23
27
}
@@ -57,7 +61,12 @@ impl Ord for Numeric {
57
61
fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
58
62
match self . partial_cmp ( other) {
59
63
Some ( ordering) => ordering,
60
- None => Ordering :: Equal , // We don't expect Postgres to send us NaNs.
64
+ None => {
65
+ if self . data . is_nan ( ) || other. data . is_nan ( ) {
66
+ warn ! ( "using NaNs in sorting, this doesn't work" )
67
+ }
68
+ Ordering :: Equal // We don't expect Postgres to send us NaNs.
69
+ }
61
70
}
62
71
}
63
72
}
You can’t perform that action at this time.
0 commit comments