Multi servers and PostgreSQL [message #7251] |
Wed, 06 February 2019 12:46 |
pdv
Messages: 15 Registered: January 2019
|
Junior Member |
|
|
Hi,
I'm trying to access some existing PostgreSQL databases on macos with Radicore.
Since I want to keep my existing (pgsql)databases unmodified, Radicore is loaded in a separate (pgsql)database and I must use several connections. In my case these are all hosted by localhost and this poses a problem.
The function &_getDBMSengineByHost ($dbhost) in dict_databse_s01.class.inc loops over servers until a matching host is found and then breaks the loop, so that of e.g. 2 different (pgsql) servers on localhost, only one can be reached.
I solved this by passing the server(number) instead of the host: function &_getDBMSengineByServer ($server) and then no looping is needed since $server can directly be used as an index in the $servers array.
Regards,
Patrick
|
|
|
Re: Multi servers and PostgreSQL [message #7255 is a reply to message #7251] |
Thu, 07 February 2019 05:02 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
PostgreSQL is peculiar in that it has the hierarchy server->database->schema->table instead of the common server->database->table. Tables are known as "database tables" and not "schema tables", so the introduction of a level between "database" and "table" is clearly non-standard and IMHO clearly wrong. I have yet to see a method of switching between one database and another in postgres within the same connection, so Radicore does not support this. This means that all the schemas which you wish to access *MUST* reside in the same database. It is possible to open multiple connections to different servers, but it is not possible for a single database transaction to span multiple connections.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|
|
Re: Multi servers and PostgreSQL [message #7271 is a reply to message #7266] |
Mon, 11 February 2019 04:45 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The amended code which you sent me actually contains a bug. The first argument in the _loadDatabases() method you changed from $dbhost to $server, yet the first line of the method is still referring to $dbhost. As it has not been defined the first condition always fails.
When using the multi-server option you *MUST* supply a value for PGSQL_dbname in each entry of the $servers array.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|