| From: | "Joel Jacobson" <joel(at)compiler(dot)org> | 
|---|---|
| To: | "David Fetter" <david(at)fetter(dot)org> | 
| Cc: | "Aleksander Alekseev" <aleksander(at)timescale(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: [PATCH] Add get_bytes() and set_bytes() functions | 
| Date: | 2024-08-15 04:19:36 | 
| Message-ID: | 81b14d60-e200-4644-8145-10da654ed334@app.fastmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2024-08-15 05:14:26 | Re: Variable renaming in dbcommands.c | 
| Previous Message | SAMEER KUMAR | 2024-08-15 03:25:25 | Re: Adding clarification to description of IPC wait events XactGroupUpdate and ProcArrayGroupUpdate |