question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PostgreSQL : "Tools/Execute script" on a database => executed on the wrong database

See original GitHub issue

System information:

  • Operating system (distribution) and version : Windows 10
  • DBeaver version : 6.3.3
  • Additional extensions : none

Connection specification:

  • Database name and version : PostgreSQL
  • Driver name : PostgreSQL JDBC Driver
  • Do you use tunnels or proxies (SSH, SOCKS, etc)? No

Describe the problem you’re observing:

Since upgrading to DBeaver 6.3.2 and 6.3.3, scripts are not executed on the selected database, but on another database. I have several databases on the same PostgreSQL server, and I want to execute a script on each of the databases :

  • Right click on the initial database (database_dev), and select Tools/execute script : window open, OK
  • Select the script and run it : script run, OK
  • Right click on another database (database_prod), and select Tools/execute script : window open, OK
  • Select the script and run it : script run on the other database, and the log is incoherent :
C:\Users\nvervell\AppData\Roaming\DBeaverData\drivers\clients\postgresql\win\psql.exe --host=my-host-postgresql.postgres.database.azure.com --port=5432 --username=user@my-host-postgresql --echo-errors database_dev
Task 'PostgreSQL script' started at Tue Jan 21 12:32:02 CET 2020
...
Task 'PostgreSQL script' finished at Tue Jan 21 12:32:08 CET 2020
2020-01-21 12:32:09.047 - Initiate connection to PostgreSQL database [user@my-host-postgresql.postgres.database.azure.com] for Main <database_prod>
2020-01-21 12:32:09.614 - Initiate connection to PostgreSQL database [user@my-host-postgresql.postgres.database.azure.com] for Metadata <database_prod>

As you can see, at the beginning of the log the command ends with “database_dev” (while I selected “database_prod” as the target), but at the end of the log it says “database_prod”.

It was working properly before the upgrade (I was using DBeaver 6.2.x), and I changed nothing in the configuration. I tried to create a separate connection for each database, rather than using the same connection, but nothing changed.

Steps to reproduce, if exist:

Include any warning/errors/backtraces from the logs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
WPCleanercommented, Jan 21, 2020

I had a similar problem. Likely related to #7693 - the DB you think is active is not the one that is actually active.

With previous versions, it wasn’t depending on the active DB : using the contextual menu (Tools / Execute script) on a DB would run the script on this DB, whether or not it’s the active DB.

0reactions
uslsscommented, Jan 27, 2020

verified

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: psql - PostgreSQL
When program is specified, command is executed by psql and the data passed from or to command is routed between the server and...
Read more >
Run a PostgreSQL .sql file using command line arguments
If the database is remote, use the same command with host ... Use this to execute *.sql files when the PostgreSQL server is...
Read more >
2 Using SQL Scripts
You can cut and paste a SQL command from the SQL Script editor to run it in SQL Commands. ... See "Managing Database...
Read more >
sp_execute_external_script (Transact-SQL) - SQL Server
Requires EXECUTE ANY EXTERNAL SCRIPT database permission. Examples. This section contains examples of how this stored procedure can be used to ...
Read more >
Run queries | DataGrip Documentation - JetBrains
Open the Files tool window (View | Tool Windows | Files) and double-click ... In order to run SQL scripts, treat the usages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found