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

Added support to override the protocol used when connecting to Oracle. #6593

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

martinedge
Copy link

@martinedge martinedge commented Nov 12, 2024

TCPS is required to be passed in the EasyConnectString to connect to Autonomous databases. Tested against an Oracle Cloud instance using TLS authentication.

Q A
Type feature/improvement

Fixes #6593.

Summary

Attempted to connect to an autonomous database within Oracle OCI Cloud. Identified the protocol needs to be changed within the connection string to match their requirements. Added a parameter to permit this override.

TCP remains the default, can be overridden by TCPS and TCPS only.

@@ -70,14 +70,21 @@ public static function fromConnectionParameters(array $params): self
$connectData['INSTANCE_NAME'] = $params['instancename'];
}

$protocol = 'TCP';
if (isset($params['protocol'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should stop putting driver-specific parameters into the driver-agnostic $params. Please try moving it to driver options.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @morozov - It's an Oracle parameter rather than a driver-specific function. You'll find it used when you generate a connection string from within OCI Cloud.

It's not dissimilar to how it's done in java - as much as it's driven within an oracle namespace.

Where else would you suggest I put this if not in an AbstractOracleDriver/EasyConnectString.php ?

Also noting that 'TCP' as the protocol is already set statically in this portion of code?

Cheers!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an Oracle parameter rather than a driver-specific function.

So… it's a parameter that we only ever need when connecting through the Oracle drivers which makes it very driver-specific.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @derrabus - and the change is in AbstractOracleDriver - am I missing something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @morozov said, $params is driver-agnostic. That's regardless of which class receives it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah now I follow what was being said.

I’ll look at the other drivers to see how specific database settings are made available

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg0ire @derrabus @morozov I have moved the configuration item into driverOptions, in line with the 'exclusive' configuration item that already existed. Hopefully, that's better.

@derrabus derrabus changed the base branch from 4.2.x to 4.3.x November 15, 2024 07:49
@derrabus derrabus changed the base branch from 4.3.x to 4.2.x November 15, 2024 07:49
Comment on lines 25 to 27
(new Driver())->connect([
'driverOptions' => ['protocol' => 'TCPS'],
]);
Copy link
Member

@morozov morozov Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have a functional test instead. Is it possible to query some system view and get the protocol of the current connection? Otherwise, this test doesn't prove anything.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov I can check, but if you got the protocol wrong, it would not connect in the first place, so would I not be creating a test that would in theory never succeed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm talking about testing the happy path. If the user provides a valid value, the connection should be established using this protocol.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov OK. looking into it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov The closest I can find in Oracle is via v$session_conn_info:

select * from V$SESSION_CONNECT_INFO;

(DESCRIPTION=(address=(protocol=tcps)(port=1521)(host=1.1.1.1))(CONNECT_DATA=(CID=(PROGRAM=DataGrip)(HOST=__jdbc__)(USER=xxxx))(service_name=xxxxx.oraclecloud.com)(CONNECTION_ID=xxxxxxx)(SERVER=dedicated)(INSTANCE_NAME=xxxx))(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521)(publish_service_acl=true))(SOURCE_ROUTE=YES)(HOP_COUNT=2))
I would have to parse that string then to get the answer unless a pattern match would be OK. I'm working on the 'existence' of protocol=tcps - because there may be some magic in Oracle cloud where it is likely passing via TCP internally.

What are your thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg0ire I believe I have it this time - although the message is a bit skewiff with the note about 'combination of 2 commits'. Says 1 commit now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the number of commits, we're good now, congrats!

Regarding the message itself, I don't know how you managed to do that 🤣

Can tell me what git config --get 'commit.cleanup' prints? I suspect an unexpected configuration on your end.

If I run git commit --amend, the comments disappear, as expected.
Can you try git commit --amend --no-edit --cleanup=strip && git push --force?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg0ire, thanks for guiding @martinedge here. If it takes too much effort on your end, and if the author doesn't mind, we could amend the commit ourselves.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morozov I don't mind, if you want me to work through the process, I'm happy to either way, as it might save me mucking it up in the future :-) Up to you all, thankyou for your support!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the regular git commit --amend && git push --force.

@@ -312,6 +312,7 @@ pdo_oci / oci8
connection pooling.
- ``charset`` (string): The charset used when connecting to the
database.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra line you've introduced.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This protocol is generally required when connecting to Oracle Cloud's
Autonomous Databases.
@morozov morozov force-pushed the oracle-connect-via-tcps branch from e877129 to 8e4a40a Compare November 23, 2024 01:01
@morozov morozov merged commit 47deee8 into doctrine:4.2.x Nov 23, 2024
92 checks passed
@morozov
Copy link
Member

morozov commented Nov 23, 2024

Thanks, @martinedge.

@morozov
Copy link
Member

morozov commented Nov 23, 2024

Actually, it should have gone to 4.3.x since it's a new feature but it looks safe. Maintainers, please let me know if you think we should revert and retarget.

@morozov morozov added this to the 4.2.2 milestone Nov 23, 2024
@martinedge martinedge deleted the oracle-connect-via-tcps branch November 23, 2024 02:44
@greg0ire
Copy link
Member

It looks safe indeed. I think one way to notice that kind of mistake is to form the habit of assigning the milestone right before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants