auto type casting bug

From: Matthew Manuel <mmanuel(at)peer1(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: auto type casting bug
Date: 2005-08-25 20:05:11
Message-ID: 430E2477.6010804@peer1.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello, I found a strange error which occurs when I run a query from
PHP4, where if there is a column which has strings arbitrarily defined
text for all rows of a sub-select, and you attempt to sort by that
column, it cannot determine the type for that column in order to do the
sort.

- If you UNION more than one of these rows, the UNION seems to determine
the data type for the column, so the sort works.
- If the values are integers, the error does not occur
- if each arbitrary text value is explicitly cast, the error does not
occur. I have not tested other data types.
- This error does NOT occur when the query is run in the psql command line.

If you have any8 questions, please feel free to contact me.

Thanks,
-Matthew

Here is an example PHP page I wrote to demonstrate:

query1:
SELECT a.col1, a.col2
FROM (
SELECT 'test row' AS col1, 1 AS col2
) AS a
ORDER BY a.col1
Running...

*Warning*: pg_query(): Query failed: ERROR: failed to find conversion function from "unknown" to text in */home3/manuel.ca/test/pgtest.php* on line *14*

done

query2:
SELECT a.col1, a.col2
FROM (
SELECT 'test row' AS col1, 1 AS col2
) AS a
ORDER BY a.col2
Running...
done

query3:
SELECT a.col1, a.col2
FROM (
SELECT 'test row' AS col1, 1 AS col2
UNION
SELECT 'next row' AS col1, 2 AS col2
) AS a
ORDER BY a.col1
Running...
done

query4:
SELECT a.col1, a.col2
FROM (
SELECT 'test row'::text AS col1, 1 AS col2
) AS a
ORDER BY a.col1
Running...
done

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gennadiy.Donchyts 2005-08-25 23:50:59 Re: BUG #1844: Failed to start service 'PostgreSQL Database Server 8.0'
Previous Message Eric Boutin 2005-08-25 18:41:59 BUG #1848: Segfault with pg_dump when database name omitted