I had a Postgresql DB on a Virtual Machine and I have used below line of code is several functions.
PERFORM dblink_connect('dbname=db_name user=postgres')
Now I am migrating to Azure Postgresql, After several days of process, I have moved the entire application setup to Azure. However I have noticed that all the functions which have above line of code are failing with error below.
SQL Error [2F003]: ERROR: password is required
Detail: Non-superusers must provide a password in the connection string.
Where: SQL statement "SELECT public.dblink_connect(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432 user=postgres')"
I have changed the code and tried below options too, but with no success.
Option 1
Added password to the code
PERFORM dblink_connect('dbname=db_name user=postgres password=*****')
Error 1
SQL Error [2F003]: ERROR: password is required
Detail: Non-superuser cannot connect if the server does not request a password.
Hint: Target server's authentication method must be changed.
Where: SQL statement "SELECT public.dblink_connect(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432 user=postgres password=*****')"
Option 2
Notice that I added _u to the function dblink_connect. (This is per some online articles)
PERFORM dblink_connect_u('dbname=db_name user=postgres password=*****')
Error 2
SQL Error [2F003]: ERROR: password is required
Detail: Non-superuser cannot connect if the server does not request a password.
Hint: Target server's authentication method must be changed.
Where: SQL statement "SELECT public.dblink_connect_u(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432 user=postgres password=*****')"
Per the Errors, the user (postgres) need to be a superuser for the code to work, however what I have read on Azure documentation is that a superuser can not be created on an Azure postgresql.
Is it really not possible to create a Superuser on Azure Postgres DB?
If not, then How can I make the below code work, Any options would be greatly helpful.
If there is no solution to this, then unfortunately I need to roll back the PostgresDB to VM again.