4

I just installed Azure Data Studio (ADS) and PostgreSQL extension. ADS connects to my Postgresql and I can do queries on my database. However, the dropdown 'Databases' tab does not expand. When I right click, to do Refresh, an error message shows up "Error: Failed to expand node". Would someone please help? Thank you so much in advance.

TimB
  • 71
  • 1
  • 9

3 Answers3

7

For folks on MacOS, here's the requisite file:

~/.azuredatastudio/extensions/microsoft.azuredatastudio-postgresql-0.2.7/out/ossdbtoolsservice/OSX/v1.5.0/pgsqltoolsservice/lib/pgsmo/objects/database/templates/+default/nodes.sql

And for completions sake, the updated contents:

{#
 # pgAdmin 4 - PostgreSQL Tools
 #
 # Copyright (C) 2013 - 2017, The pgAdmin Development Team
 # This software is released under the PostgreSQL Licence
 #}
SELECT
    db.oid as oid,
    db.datname as name,
    ta.spcname as spcname,
    db.datallowconn,
    0 As datlastsysoid,
    has_database_privilege(db.oid, 'CREATE') as cancreate,
    datdba as owner,
    db.datistemplate ,
    has_database_privilege(db.datname, 'connect') as canconnect,
    datistemplate as is_system

FROM
    pg_database db
    LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace = ta.oid
{% if did %}
WHERE db.oid = {{ did|qtLiteral }}::OID
{% elif last_system_oid %}
WHERE db.oid > {{ last_system_oid }}::OID
{% endif %}

ORDER BY datname;
Rachel Ambler
  • 1,440
  • 12
  • 23
6

Followed Crocodilus's instruction to edit the nodes query replacing line db.datlastsysoid with 0 as datlastsysoid worked for me. One update is adding a slash after the userprofile reference: %USERPROFILE%\.azuredatastudio\extensions\microsoft.azuredatastudio-postgresql-0.2.7\out\ossdbtoolsservice\Windows\v1.5.0\pgsqltoolsservice\lib\pgsmo\objects\database\templates\+default\nodes.sql

5

Seems to be a known issue with ADS since pg_database.datlastsysoid field was removed in PostgreSQL 15. I am also waiting for a solution.

Azure Data Studio issue: https://github.com/microsoft/azuredatastudio-postgresql/issues/333

Rationale for removing datlastsysoid in version 15: https://www.postgresql.org/message-id/CA%2BTgmoa14%3DBRq0WEd0eevjEMn9EkghDB1FZEkBw7%2BUAb7tF49A%40mail.gmail.com

Crocodilus
  • 51
  • 1
  • Thank you for the information. That clears up my understanding. – TimB Nov 19 '22 at 14:59
  • 10
    @TimB Found a short-term fix posted [here](https://github.com/microsoft/azuredatastudio-postgresql/issues/334#issuecomment-1316757208) by Aidan-Chang. go to `%USERPROFILE%.azuredatastudio\extensions\microsoft.azuredatastudio-postgresql-0.2.7\out\ossdbtoolsservice\Windows\v1.5.0\pgsqltoolsservice\lib\pgsmo\objects\database\templates\+default\nodes.sql` replace line `db.datlastsysoid,` with `0 as datlastsysoid,` in the sql text. save and reopen the azure data studio – Crocodilus Nov 22 '22 at 04:14
  • Thank you for taking the time to answer my question. Let me try that to see how far I get. Much appreciated! – TimB Dec 11 '22 at 21:48