Re: [PATCH] Add get_bytes() and set_bytes() functions
От | Joel Jacobson |
---|---|
Тема | Re: [PATCH] Add get_bytes() and set_bytes() functions |
Дата | |
Msg-id | 81b14d60-e200-4644-8145-10da654ed334@app.fastmail.com обсуждение исходный текст |
Ответ на | Re: [PATCH] Add get_bytes() and set_bytes() functions ("Joel Jacobson" <joel@compiler.org>) |
Ответы |
Re: [PATCH] Add get_bytes() and set_bytes() functions
|
Список | pgsql-hackers |
On Wed, Aug 14, 2024, at 19:25, Joel Jacobson wrote: > What do we want to happen if passing a numeric with decimal digits, > to decimal_to_bytes()? It must be an error, right? > > Example: SELECT decimal_to_bytes(1.23); Hmm, an error feels quite ugly on second thought. Would be nicer if all numerics could be represented, in a bytea representation that is meaningful to other systems. I think we need a tuple somehow. Example: SELECT numeric_to_bytes(223195403574957); (\xcafebabedeadbeef,0,false) SELECT numeric_to_bytes(-223195403574957); (\xcafebabedeadbeef,0,true) SELECT numeric_to_bytes(2231954035749.57); (\xcafebabedeadbeef,2,false) SELECT numeric_from_bytes('\xcafebabedeadbeef'::bytea,0,false); 223195403574957 SELECT numeric_from_bytes('\xcafebabedeadbeef'::bytea,0,true); -223195403574957 SELECT numeric_from_bytes('\xcafebabedeadbeef'::bytea,2,false); 2231954035749.57 But then what about Inf,-Inf,NaN? Regards, Joel
В списке pgsql-hackers по дате отправления: