summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2004-03-15 01:13:41 +0000
committerTom Lane2004-03-15 01:13:41 +0000
commit89ab5c4abf48de8156b9284dda869f9ea2b2ad44 (patch)
tree00b04c3c9edb91919fba7969083e71f38f2d12db /src/test
parent64fe1fd2394cfd14346cef3845529b053a1d5998 (diff)
Remove grotty special-case code in coerce_to_target_type() that
implemented casts to varchar and bpchar using a cast-to-text function. This is a holdover from before we had pg_cast; it now makes more sense to just list these casts in pg_cast. While at it, add pg_cast entries for the other direction (casts from varchar/bpchar) where feasible.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/opr_sanity.out8
-rw-r--r--src/test/regress/sql/opr_sanity.sql8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 4e2c76de5c2..b76cc695f44 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -239,11 +239,17 @@ WHERE castsource = casttarget OR castsource = 0 OR casttarget = 0
-- Look for cast functions that don't have the right signature. The
-- argument and result types in pg_proc must be the same as, or binary
-- compatible with, what it says in pg_cast.
+-- As a special case, we allow casts from CHAR(n) that use functions
+-- declared to take TEXT. This does not pass the binary-coercibility test
+-- because CHAR(n)-to-TEXT normally invokes rtrim(). However, the results
+-- are the same, so long as the function is one that ignores trailing blanks.
SELECT c.*
FROM pg_cast c, pg_proc p
WHERE c.castfunc = p.oid AND
(p.pronargs <> 1
- OR NOT binary_coercible(c.castsource, p.proargtypes[0])
+ OR NOT (binary_coercible(c.castsource, p.proargtypes[0])
+ OR (c.castsource = 'character'::regtype AND
+ p.proargtypes[0] = 'text'::regtype))
OR NOT binary_coercible(p.prorettype, c.casttarget));
castsource | casttarget | castfunc | castcontext
------------+------------+----------+-------------
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index 448f3ff0c5b..82a294db6d6 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -196,12 +196,18 @@ WHERE castsource = casttarget OR castsource = 0 OR casttarget = 0
-- Look for cast functions that don't have the right signature. The
-- argument and result types in pg_proc must be the same as, or binary
-- compatible with, what it says in pg_cast.
+-- As a special case, we allow casts from CHAR(n) that use functions
+-- declared to take TEXT. This does not pass the binary-coercibility test
+-- because CHAR(n)-to-TEXT normally invokes rtrim(). However, the results
+-- are the same, so long as the function is one that ignores trailing blanks.
SELECT c.*
FROM pg_cast c, pg_proc p
WHERE c.castfunc = p.oid AND
(p.pronargs <> 1
- OR NOT binary_coercible(c.castsource, p.proargtypes[0])
+ OR NOT (binary_coercible(c.castsource, p.proargtypes[0])
+ OR (c.castsource = 'character'::regtype AND
+ p.proargtypes[0] = 'text'::regtype))
OR NOT binary_coercible(p.prorettype, c.casttarget));
-- Look for binary compatible casts that do not have the reverse