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 -- Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-support