Re: Likely bug in executing pgScript on wrong database

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Charles Gutjahr <charlesg(at)ourcommunity(dot)com(dot)au>
Cc: "pgadmin-support(at)postgresql(dot)org" <pgadmin-support(at)postgresql(dot)org>
Subject: Re: Likely bug in executing pgScript on wrong database
Date: 2012-02-29 09:27:28
Message-ID: 1330507648.2696.6.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Wed, 2012-02-29 at 11:22 +1100, Charles Gutjahr wrote:
> I've found what appears to be a bug in the way pgAdmin III executes pgScript, which can cause it to run scripts on the wrong database. I couldn't find any records of the bug in your Trac site, so I'm reporting it here.
>
> Here's how to reproduce. In this example, assume I have two databases called 'one' and 'two' on a PostgreSQL server:
>
> * Open pgAdmin III
> * Connect to a server and click on database 'one' in the object browser
> * Click the SQL button in the toolbar to open a query window
> * Click the dropdown at the top of the query window, choose <new connection>
> * Choose database 'two' and click OK to connect
> * The query window (and dropdown) now shows that I am connected to database 'two'
> * Write some SQL in the query window and execute it -- it executes on database 'two'
> * Write some pgScript SQL in the query window and execute it -- it executes on database 'one'
>
> In other words, it seems that pgScript is executed on the original connection that existed when the query window was opened, not the current connection that you have selected later. The problem occurs regardless of whether the connections are to the same server or different servers. As you might imagine, this caused some confusion and heartache here for us!
>
> A simple way to test this is to use the current_database() function in your SQL like this:
>
> -- SQL
> select current_database();
>
> -- pgScript
> declare @db;
> set @db = select current_database();
> print @db;
>
> You should find that they return different results if you've followed the steps above.
>

Yes, it's definitely a bug. I fixed it a few minutes ago.

Thanks for your report.

--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Guillaume Lelarge 2012-02-29 22:42:38 Re: feature request - show role members
Previous Message Dave Page 2012-02-29 09:13:17 Re: PG 9.1 Windows 7 64-bit pgAdmin says all pgAgent jobs fail