Re: Problème pour surcharger la fonction substring

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: "Delorme, Yann" <Yann(dot)Delorme(at)esker(dot)fr>
Cc: "pgsql-fr-generale(at)postgresql(dot)org" <pgsql-fr-generale(at)postgresql(dot)org>
Subject: Re: Problème pour surcharger la fonction substring
Date: 2011-04-20 10:07:03
Message-ID: 4DAEB047.9000201@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Le 20/04/2011 11:27, Delorme, Yann a écrit :
> POSTGRE 9.0.3 et POSTGRE 9.0.4
>
> Bonjour
>
> Je cherche à surcharger la fonction substring pour quelle fonctionne avec les dates et les time stamps.
> Je migre une application existante et pour l'instant je ne peux pas faire autrement, car le code doit fonctionner sur 2 SGDB différents.
>
> J'ai défini la fonction suivante :
>
> -- Function: "substring"(timestamp without time zone, integer, integer)
>
> -- DROP FUNCTION "substring"(timestamp without time zone, integer, integer);
>
> CREATE OR REPLACE FUNCTION "substring"(timestamp without time zone, integer, integer)
> RETURNS text AS
> 'select pg_catalog.substring($1::text, $2, $3)'
> LANGUAGE sql IMMUTABLE STRICT
> COST 1;
> ALTER FUNCTION "substring"(timestamp without time zone, integer, integer) OWNER TO postgres;
>
>
> Mais pour appeler ma fonction je suis obligé le préfixer l'appel par public. Sinon j'ai l'erreur suivante :
>
>
> ERROR: function pg_catalog.substring(timestamp without time zone, integer, integer) does not exist
> LINE 1: select substring(sub_date_time, 1, 7), sub_date_time from "D...
> ^
> HINT: No function matches the given name and argument types. You might need to add explicit type casts.
>
> ********** Erreur **********
>
> ERROR: function pg_catalog.substring(timestamp without time zone, integer, integer) does not exist
> État SQL :42883
> Astuce : No function matches the given name and argument types. You might need to add explicit type casts.
> Caractère : 8
>
> J'ai modifié le searchpath
> SET search_path TO public,pg_catalog
>
> Mais cela ne change rien.
>
> Auriez-vous une idée pour que mon select fonctionne sans préfixer l'appel par public ?
>

À ma connaissance, pg_catalog est toujours inclus en premier. Donc, non,
pas moyen de faire sans préfixer par le schéma. La raison en est que ça
ouvrirait une grosse brèche de sécurité dans le cas contraire.

--
Guillaume
http://www.postgresql.fr
http://dalibo.com

In response to

Responses

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Delorme, Yann 2011-04-20 12:04:43 RE: Problème pour surcharger la fonction substring
Previous Message Delorme, Yann 2011-04-20 09:27:43 Problème pour surcharger la fonction substring