Unix Technical Forum

plpgsql: Plan type mismatch error

This is a discussion on plpgsql: Plan type mismatch error within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi hackers, I recently ran afoul of the following error message: ERROR: type of "varname" does not match that ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 10:28 PM
Brendan Jurd
 
Posts: n/a
Default plpgsql: Plan type mismatch error

Hi hackers,

I recently ran afoul of the following error message:

ERROR: type of "varname" does not match that when preparing the plan

IMO the message isn't quite in English and doesn't explain the problem
very well. I'd like to change it to something more like

ERROR: the type of "varname" does not match the type expected by the planner
HINT: Ensure that the type does not change between function calls, or
use EXECUTE instead

Comments?

Regards,
BJ

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 10:28 PM
Tom Lane
 
Posts: n/a
Default Re: plpgsql: Plan type mismatch error

"Brendan Jurd" <direvus@gmail.com> writes:
> I recently ran afoul of the following error message:
> ERROR: type of "varname" does not match that when preparing the plan
> IMO the message isn't quite in English and doesn't explain the problem
> very well.


The English is fine. What I want to know about is whether this was a
current release, and if so how you provoked it.

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 10:28 PM
Brendan Jurd
 
Posts: n/a
Default Re: plpgsql: Plan type mismatch error

On 10/16/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Brendan Jurd" <direvus@gmail.com> writes:
> > I recently ran afoul of the following error message:
> > ERROR: type of "varname" does not match that when preparing the plan
> > IMO the message isn't quite in English and doesn't explain the problem
> > very well.

>
> The English is fine. What I want to know about is whether this was a
> current release, and if so how you provoked it.


This was in 8.3 beta 1. I provoked the message by having a variable
which came from a dynamic query (EXECUTE .. INTO a variable of type
RECORD), and a member of that record changed type between one
execution of the function and the next.

So the plan was cached on the first execution, and in the second
execution the type of the variable did not match the type in the plan.
At least, that's what I understand happened from looking at the code
which emitted the message.

Once I knew what the message was talking about, fixing my function was
easy. It's a useful error message, it's just not well articulated ...

Cheers,
BJ

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 10:28 PM
Pavel Stehule
 
Posts: n/a
Default Re: plpgsql: Plan type mismatch error

2007/10/16, Brendan Jurd <direvus@gmail.com>:
> On 10/16/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > "Brendan Jurd" <direvus@gmail.com> writes:
> > > I recently ran afoul of the following error message:
> > > ERROR: type of "varname" does not match that when preparing the plan
> > > IMO the message isn't quite in English and doesn't explain the problem
> > > very well.

> >
> > The English is fine. What I want to know about is whether this was a
> > current release, and if so how you provoked it.

>
> This was in 8.3 beta 1. I provoked the message by having a variable
> which came from a dynamic query (EXECUTE .. INTO a variable of type
> RECORD), and a member of that record changed type between one
> execution of the function and the next.
>
> So the plan was cached on the first execution, and in the second
> execution the type of the variable did not match the type in the plan.
> At least, that's what I understand happened from looking at the code
> which emitted the message.
>
> Once I knew what the message was talking about, fixing my function was
> easy. It's a useful error message, it's just not well articulated ...
>
> Cheers,
> BJ
>

please, read:
http://www.pgsql.cz/index.php/Automa...ng_in_PL/pgSQL

Pavel

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 10:28 PM
Brendan Jurd
 
Posts: n/a
Default Re: plpgsql: Plan type mismatch error

On 10/16/07, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> please, read:
> http://www.pgsql.cz/index.php/Automa...ng_in_PL/pgSQL
>


Thanks Pavel,

I actually came across that wiki article via Google when I was first
trying to learn more about the message. But, I'm not asking for help
understanding how plan caching works. As mentioned, I've already
fixed the problem with my function.

Rather, I'm suggesting that we increase the helpfulness of the error message.

BJ

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com