pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Carsten Klein <c.klein@datagis.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Strange results when casting string to double
Date: Fri, 18 Feb 2022 15:07:47 -0500
Message-ID: <4137023.1645214867@sss.pgh.pa.us> (raw)
In-Reply-To: <6593fee3-477b-6069-f91e-79f91075808f@datagis.com>
References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com>
	<f3575aaf-98a8-6941-7843-ba1a0d78514f@enterprisedb.com>
	<4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com>
	<3950189.1645198347@sss.pgh.pa.us>
	<6593fee3-477b-6069-f91e-79f91075808f@datagis.com>

Carsten Klein <c.klein@datagis.com> writes:
> So, you're not aware of any ways this behavior could be achieved from 
> within PostgreSQL? Something like a custom cast (actually, there is 
> none) or something that could intercept string to double conversion? 

Well, you asserted that these installations are all alike ... but
sure, it's conceivable that somebody could've replaced the default
numeric -> float8 cast (i.e., numeric_float8()) with some other code
that does it a bit inaccurately.  There's only a pg_cast entry
connecting that function to those types.  Have you tried stepping
through things with a debugger, to see if numeric_float8 and float8in
are actually reached on the problematic system?

> That would be something to look at closer. The question is: how would 
> you implement such an evil database wide text to double conversion (just 
> to kid users) if you had to?

At the SQL level, your example does not involve text -> double.
The literal 1.56 is of type numeric.

			regards, tom lane





view thread (24+ messages)  latest in thread

Message-ID: <4137023.1645214867@sss.pgh.pa.us>
Permalink:  ../4137023.1645214867@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4137023.1645214867@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, c.klein@datagis.com, peter.eisentraut@enterprisedb.com
  Subject: Re: Strange results when casting string to double
  In-Reply-To: <4137023.1645214867@sss.pgh.pa.us>
  References: <0d711ac6-6975-ae07-8963-aa91c6500776@datagis.com> <f3575aaf-98a8-6941-7843-ba1a0d78514f@enterprisedb.com> <4592fac1-05b2-f775-3332-c5a7d4c65b9d@datagis.com> <3950189.1645198347@sss.pgh.pa.us> <6593fee3-477b-6069-f91e-79f91075808f@datagis.com> <4137023.1645214867@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox