Обсуждение: BUG: type of "xxxx" does not match that when preparing the plan

Поиск
Список
Период
Сортировка

BUG: type of "xxxx" does not match that when preparing the plan

От
Hubert FONGARNAND
Дата:
Hi,<br /><br /> We are testing PostGreSQL 8.3 RC2 on our beta plateform and we are facing some problems with plpgsql
function.<br/><br /> Here's a failing test case, which worked well on postgresql 8.1 :<br /><br /><pre>
 
Create this function :

CREATE OR REPLACE FUNCTION test(param integer)
  RETURNS text AS
$BODY$DECLARE
       attribute TEXT:='';
       query TEXT;
       curs REFCURSOR;
       rec RECORD;
BEGIN 
if (param=1) THENquery := 'SELECT ''test''::varchar AS label';ELSE query := 'SELECT ''test''::text AS label';END IF;
RAISE NOTICE '%',query;
OPEN curs for EXECUTE query;
FETCH curs into rec;
attribute=rec.label;
CLOSE curs;

RETURN attribute;
END;$BODY$
  LANGUAGE 'plpgsql' VOLATILE

Execute this function, and this sql :

postgres=# SELECT test(1);
NOTICE:  SELECT 'test'::varchar AS labeltest 
------test
(1 ligne)

and now :
postgres=# SELECT test(2);
NOTICE:  SELECT 'test'::text AS label
ERROR:  type of "rec.label" does not match that when preparing the plan
CONTEXT:  PL/pgSQL function "test" line 15 at assignment


It seems that if the type of "label" changes from varchar to text it crashes...

Thanks for fixing this!
Hubert FONGARNAND

</pre><br /> _________________________________________________ <br /> Ce message et les eventuels documents joints
peuventcontenir des informations confidentielles. Au cas ou il ne vous serait pas destine, nous vous remercions de bien
vouloirle supprimer et en aviser immediatement l'expediteur. Toute utilisation de ce message non conforme a sa
destination,toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Lescommunications sur internet n'etant pas securisees, l'integrite de ce message n'est pas assuree et la societe
emettricene peut etre tenue pour responsable de son contenu.  

Re: BUG: type of "xxxx" does not match that when preparing the plan

От
Tom Lane
Дата:
Hubert FONGARNAND <informatique.internet@fiducial.fr> writes:
> We are testing PostGreSQL 8.3 RC2 on our beta plateform and we are
> facing some problems with plpgsql function.

> Here's a failing test case, which worked well on postgresql 8.1 :

Really?  I get the 'does not match' error in every release back to 7.3.
        regards, tom lane


Re: BUG: type of "xxxx" does not match that when preparing the plan

От
Hubert FONGARNAND
Дата:
I'm sorry, you're right it fails too with older version of postgresql<br /><br /><br /> Le jeudi 31 janvier 2008 à
10:35-0500, Tom Lane a écrit : <blockquote type="CITE"><pre>
 
<font color="#000000">Hubert FONGARNAND <<a
href="mailto:informatique.internet@fiducial.fr">informatique.internet@fiducial.fr</a>>writes:</font>
 
<font color="#000000">> We are testing PostGreSQL 8.3 RC2 on our beta plateform and we are</font>
<font color="#000000">> facing some problems with plpgsql function.</font>

<font color="#000000">> Here's a failing test case, which worked well on postgresql 8.1 :</font>

<font color="#000000">Really?  I get the 'does not match' error in every release back to 7.3.</font>

<font color="#000000">            regards, tom lane</font>
</pre></blockquote><br /> _________________________________________________ <br /> Ce message et les eventuels
documentsjoints peuvent contenir des informations confidentielles. Au cas ou il ne vous serait pas destine, nous vous
remercionsde bien vouloir le supprimer et en aviser immediatement l'expediteur. Toute utilisation de ce message non
conformea sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est
formellementinterdite. Les communications sur internet n'etant pas securisees, l'integrite de ce message n'est pas
assureeet la societe emettrice ne peut etre tenue pour responsable de son contenu.