mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
For a statement which only specify the database, we expect the data node to be created on the same Postgres instance as the one where the statement is executed. SELECT * FROM add_data_node('data1', database => 'base1'); However, if the port for the server is changed in the configuration file to not use the default port, the command will try to connect to the wrong Postgres server, namly the one listening on port 5432. This commit fixes this by letting `host` and `port` parameters be NULL by default and use the following logic to decide what port should be used. - If a port is explicitly provided, use that. - If a port is not provided but a host is provided, it is assumed that the intention is to connect to a default-installed Postgres server on a different address, so use the default Postgres port (5432). - If neither port nor host is provided, it assumed that the intention is to connect to the same server as where the command is executed, so use the port that was written in the configuration file. The default host to use is still 'localhost', but it is not written explicitly in the function definition in `ddl_api.sql`. The commit also fixes one warning where an uninitialized variable could be used.