[HACKERS] Built-in casts for ltree

2005-01-24 Thread Jim C. Nasby
contrib/ltree includes text2ltree and ltree2text functions, but no
implicit casts. Is there any particular reason for this?

--- ltree.sql.in.orig   Mon Jan 24 22:47:01 2005
+++ ltree.sql.inMon Jan 24 22:58:40 2005
@@ -155,10 +155,14 @@
 AS 'MODULE_PATHNAME'
 LANGUAGE 'C' WITH (isstrict,iscachable);
 
+CREATE CAST (ltree AS text) WITH FUNCTION ltree2text(ltree) AS IMPLICIT;
+
 CREATE FUNCTION text2ltree(text)
 RETURNS ltree
 AS 'MODULE_PATHNAME'
 LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE CAST (text AS ltree) WITH FUNCTION text2ltree(text) AS IMPLICIT;
 
 CREATE FUNCTION lca(_ltree)
 RETURNS ltree
-- 
Jim C. Nasby, Database Consultant   [EMAIL PROTECTED] 
Give your computer some brain candy! www.distributed.net Team #1828

Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
FreeBSD: Are you guys coming, or what?

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [HACKERS] Built-in casts for ltree

2005-01-24 Thread Tom Lane
Jim C. Nasby [EMAIL PROTECTED] writes:
 contrib/ltree includes text2ltree and ltree2text functions, but no
 implicit casts. Is there any particular reason for this?

Implicit casts to or from text are evil.

regards, tom lane

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly