1

Funambol in its administration documentation has that for running on newer PostgreSQL instances which are more strict with types and casting you have to add those casts:

CREATE FUNCTION pg_catalog.text(bigint) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int8out($1));';
CREATE CAST (bigint AS text) WITH FUNCTION pg_catalog.text(bigint) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(integer) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
CREATE CAST (integer AS text) WITH FUNCTION pg_catalog.text(integer) AS IMPLICIT;

The problem is that in the same database (in PostgreSQL terminology) I have also other schemas which applications broke because of those casts (with "operator is not unique: unknown || integer" and hint "Could not choose a best candidate operator. You might need to add explicit type casts.") while they worked before.

So one solution is of course to define additional database and have only Funambol in there. But I am wondering if is there a way to define those casts so that they take effect only in Funambol's schema and not in whole database.

Mitar
  • 6,756
  • 5
  • 54
  • 86
  • 4
    The best solution is to fix the (broken) application that relies on implicit casting (which is almost always a bad thing). But that is obivously not the solution you want to hear ;) –  Jan 20 '11 at 07:31
  • I agree. The crazy thing is that they have in their administration manual/documentation written that you have to add such casts as a solution. So the problem is well known. Fixing bugs with documentation. A new paradigm for me. ;-) – Mitar Jan 25 '11 at 05:03

1 Answers1

0

No, it's not possible in the way you imagine it. Casts are identified by source and target type, and so if both types are one of the built-in types, all users of the database will see the same casts between them. The only workaround along that line would be to create clones of the built-in data types, but don't go there. ;-)

So you either need to seek a fix with Funambol, or separate your applications into different databases, and perhaps link them back together with something like dblink.

Peter Eisentraut
  • 35,221
  • 12
  • 85
  • 90
  • Yes, I have done this. Moved Funambol to separate database. Luckily (for now) it does not matter if it is isolated. But it is definitely not a nice and clean solution. – Mitar Jan 25 '11 at 05:04