1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Allow I/O conversion casts to be applied to or from any type that is a member

of the STRING type category, thereby opening up the mechanism for user-defined
types.  This is mainly for the benefit of citext, though; there aren't likely
to be a lot of types that are all general-purpose character strings.
Per discussion with David Wheeler.
This commit is contained in:
Tom Lane
2008-07-30 21:23:17 +00:00
parent 7df49cef72
commit c8572986ad
4 changed files with 43 additions and 32 deletions

View File

@ -1141,13 +1141,16 @@ SELECT like_escape( name::text, ''::citext ) =like_escape( name::text, '' ) AS t
t
(5 rows)
--- TODO: Get citext working with magic cast functions?
SELECT cidr( '192.168.1.2'::citext ) = cidr( '192.168.1.2'::text ) AS "t TODO";
ERROR: function cidr(citext) does not exist
LINE 1: SELECT cidr( '192.168.1.2'::citext ) = cidr( '192.168.1.2'::...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT '192.168.1.2'::cidr::citext = '192.168.1.2'::cidr::text AS "t TODO";
ERROR: cannot cast type cidr to citext
LINE 1: SELECT '192.168.1.2'::cidr::citext = '192.168.1.2'::cidr::te...
^
--- citext should work as source or destination of I/O conversion casts
SELECT cidr( '192.168.1.2'::citext ) = cidr( '192.168.1.2'::text ) AS "t";
t
---
t
(1 row)
SELECT '192.168.1.2'::cidr::citext = '192.168.1.2'::cidr::text AS "t";
t
---
t
(1 row)

View File

@ -323,6 +323,6 @@ SELECT COUNT(*) = 19::bigint AS t FROM try;
SELECT like_escape( name, '' ) = like_escape( name::text, '' ) AS t FROM srt;
SELECT like_escape( name::text, ''::citext ) =like_escape( name::text, '' ) AS t FROM srt;
--- TODO: Get citext working with magic cast functions?
SELECT cidr( '192.168.1.2'::citext ) = cidr( '192.168.1.2'::text ) AS "t TODO";
SELECT '192.168.1.2'::cidr::citext = '192.168.1.2'::cidr::text AS "t TODO";
--- citext should work as source or destination of I/O conversion casts
SELECT cidr( '192.168.1.2'::citext ) = cidr( '192.168.1.2'::text ) AS "t";
SELECT '192.168.1.2'::cidr::citext = '192.168.1.2'::cidr::text AS "t";