Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Multi servers and PostgreSQL
Multi servers and PostgreSQL [message #7251] Wed, 06 February 2019 12:46 Go to next message
pdv is currently offline  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 Go to previous messageGo to next message
AJM is currently offline  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.

Re: Multi servers and PostgreSQL [message #7259 is a reply to message #7255] Thu, 07 February 2019 07:46 Go to previous messageGo to next message
pdv is currently offline  pdv
Messages: 15
Registered: January 2019
Junior Member
Toni,

As explained in the other thread I want to open 2 connections in this case to 2 pgsql-databases on the same postgresql server. When I imported the databases (schemas) I only got the schemas of servers[0]. I explained why in my original message.

I think this will also be the case when e.g. accessing a MySQL server as server[0] and a PostgreSQL server as server[1], if they are both on localhost. I think that the current code assumes that different servers are on different hosts.

Regards,

Patrick
Re: Multi servers and PostgreSQL [message #7264 is a reply to message #7259] Fri, 08 February 2019 05:08 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Can you supply me with your changed script so that I can test it?

Re: Multi servers and PostgreSQL [message #7266 is a reply to message #7264] Sat, 09 February 2019 14:17 Go to previous messageGo to next message
pdv is currently offline  pdv
Messages: 15
Registered: January 2019
Junior Member
Please find herewith the modified dict_database_s01.inc and the corresponding patch file.
  • Attachment: Archive.zip
    (Size: 5.47KB, Downloaded 434 times)
Re: Multi servers and PostgreSQL [message #7271 is a reply to message #7266] Mon, 11 February 2019 04:45 Go to previous message
AJM is currently offline  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.


Previous Topic: $lock_str FOR UPDATE FOR $tablename with PostgreSQL
Next Topic: convert_parent_id_to_child_id
Goto Forum:
  


Current Time: Sat Dec 21 08:10:16 EST 2024

Total time taken to generate the page: 0.01311 seconds