Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "easy connect string" support for the Oci8Driver #2306

Closed
bobvandevijver opened this issue Jan 21, 2016 · 4 comments
Closed

Add "easy connect string" support for the Oci8Driver #2306

bobvandevijver opened this issue Jan 21, 2016 · 4 comments

Comments

@bobvandevijver
Copy link
Contributor

I am using the Oci8Driver currently with static connect information, such as host, port and dbname. These parameters are used in the AbstractOracleDriver#L114 class to generate an easy connect string, which is used to connect to the server/database.

However, I want to switch to LDAP resolving for the database host and port. The LDAP server already returns an easy connect string, which currently can not be used directly. I parse the string to retrieve the first mentioned hostname and port, which are set in the connection using a Symfony Compiler Pass (see the shortened snippet below).

/** @var DefinitionDecorator $dbal */
$matches        = array();
preg_match('/HOST=([^)]*)/ix', $connectionInfo, $matches);
$host = $matches[1];
preg_match('/PORT=([^)]*)/ix', $connectionInfo, $matches);
$port = $matches[1];
$dbal                 = $container->getDefinition('doctrine.dbal.osiris_connection');
$arguments            = $dbal->getArguments();
$arguments[0]['host'] = $host;
$arguments[0]['port'] = $port;
$dbal->setArguments($arguments);

This creates a problem when the first server does not have the database available: an error is thrown (in this case 'ORA-12505: TNS:listener does not currently know of SID given in connect descriptor') and there is no possibility to switch to the other database, although there is a connection list available during the Compiller Pass (but not during runtime).

(DESCRIPTION=
  (ADDRESS_LIST=
    (ADDRESS=
      (PROTOCOL=TCP)
      (Host=server1.host.nl)
      (Port=1521)
    )
    (ADDRESS=
      (PROTOCOL=TCP)
      (Host=server2.host.nl)
      (Port=1521)
    )
  )
  (CONNECT_DATA=
    (SERVER=DEDICATED)
    (SERVICE_NAME=PROD.host.nl)
  )
)

I believe that when the connect string can be set in the driver, that handling of such database errors can be done by the lower driver (correct me if I'm wrong).

So, it would be convenient to be able to set the connect string directly, which can be used if set. I can make a PR for this if wanted. Any opinions?

P.S.: The link in AbstractOracleDriver#L112 is no longer valid, I can fix that as well.

@Ocramius
Copy link
Member

However, I want to switch to LDAP resolving for the database host and port.

I'm not sure that we should support this out of the box ourselves.
That said, I do not fully understand what you are proposing: I suggest that you open a pull request and that we discuss the approach (and tests for it) there, so that we can see if it is a good candidate for inclusion, or whether it should just be something that lives in your codebase (with a workaround)

@deeky666
Copy link
Member

The problem I see here is that the feature request is more or less asking to be able to provide the complete connection string by hand. This is basically the same as asking for the ability of providing a complete PDO connection string. I doubt we should accept something like this for Oracle related drivers only as it looks weird then not having the ability for other drivers, too (and there will be requests about that I am sure). Telling that I am not sure if we should accept that for all drivers (which would be the only option then) as it feels error prone and we'd have to support arbitrary connection strings then...

@bobvandevijver
Copy link
Contributor Author

@deeky666 You're right, I want to provide the connection string by hand, but I do think it is a little different than from providing the PDO strings by hand. Actually, the default for Oracle is using these type of connect descriptors (or easy connect, they use both terms) in tnsnames.ora or related files (see the Oracle Naming doc & Oracle ID/Access database doc).

So, at the moment the default method for providing the connection info for Oracle DBs is not supported, although it is being used internally. PDO is the PHP solution for connecting to databases, which means that it is not the default for sharing the connections details. That way, there is a significant difference between the two.

I will make a PR soon (it doesn't need that much change actually).

@deeky666 deeky666 self-assigned this Jan 22, 2016
@deeky666 deeky666 added this to the 2.6 milestone Jan 22, 2016
@deeky666 deeky666 added Fixed and removed PR Created labels Jan 22, 2016
@Ocramius Ocramius changed the title Feature request: Easy connect string support for Oci8Driver Add "easy connect string" support for Oci8Driver Jul 22, 2017
@Ocramius Ocramius changed the title Add "easy connect string" support for Oci8Driver Add "easy connect string" support for the Oci8Driver Jul 22, 2017
@github-actions
Copy link

github-actions bot commented Aug 4, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants