| From: | Szymon Guz <mabewlun(at)gmail(dot)com> |
|---|---|
| To: | Richard Huxton <dev(at)archonet(dot)com> |
| Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Failed to autoconvert '1' to text. |
| Date: | 2013-09-06 08:39:38 |
| Message-ID: | CAFjNrYv660Ett5=OymUDNAtVR1tuBHCD5pjHrDunrzo=S7kMJg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 6 September 2013 10:33, Richard Huxton <dev(at)archonet(dot)com> wrote:
> On 06/09/13 09:13, Szymon Guz wrote:
>
>> Hi,
>> why isn't 'aa' always treated as string?
>>
>
> with x as (
>> select
>> '1' a,
>> '2' b
>> )
>> SELECT levenshtein(a, b), length(a)
>> FROM x;
>>
>> ERROR: failed to find conversion function from unknown to text
>>
>
> Why should I cast '1' to '1'::TEXT to satisfy a function (TEXT, TEXT)?
>>
>
> I think it's to do with the CTE. Presumably its types get fixed separately
> from the SELECT levenshtein() call. A quoted literal is type "unknown"
> until it has a context. It could be a date, point, hstore etc.
>
> If you use the literals directly the context lets PostgreSQL figure it out.
> SELECT levenshtein('1','2');
>
>
>
Yep, I can use literals without any problem, as this function is
levenshtein(text, text).
| From | Date | Subject | |
|---|---|---|---|
| Next Message | 高健 | 2013-09-06 08:58:00 | Re: My Experiment of PG crash when dealing with huge amount of data |
| Previous Message | Richard Huxton | 2013-09-06 08:33:18 | Re: Failed to autoconvert '1' to text. |