dbTalk Databases Forums  

[BUGS] Cached PL/PGSQL query plan failure

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Cached PL/PGSQL query plan failure in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Donald Fraser
 
Posts: n/a

Default [BUGS] Cached PL/PGSQL query plan failure - 06-04-2004 , 12:31 PM






PostgreSQL 7.4.2 on i386-redhat-linux-gnu, compiled by GCC 2.96
OS: Redhat 7.2

Snippet of code which fails:

squery := ''SELECT '' || scolname || '' AS s_data FROM '' || stblname || ''
WHERE id = '' || idrow || '' LIMIT 1'';
FOR data_rec IN EXECUTE squery LOOP
IF (text(sdata) = text(data_rec.s_data)) OR (data_rec.s_data IS NULL AND
sdata IS NULL) THEN
RETURN VOID;
END IF;
END LOOP;

Error message:
ERROR: type of "data_rec.s_data" does not match that when preparing the plan

I get this message if I call the above code once per transaction and the
difference between the transactions is that the data type returned in the
dynamic query is not the same.
I would understand it better if I were calling this piece of code multiple
times with in the one transaction - but I am not.
To over come this problem I had to change the dynamic query as such:

squery := ''SELECT text('' || scolname || '') AS s_data FROM '' || stblname ||
'' WHERE id = '' || idrow || '' LIMIT 1'';
FOR data_rec IN EXECUTE squery LOOP
IF (text(sdata) = data_rec.s_data) OR (data_rec.s_data IS NULL AND sdata IS
NULL) THEN
RETURN VOID;
END IF;
END LOOP;


Regards
Donald Fraser


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.