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

SQLAnywhere corrections for DSN generation and persistent connections #2405

Merged
merged 6 commits into from
Feb 9, 2017

Conversation

andipohl
Copy link

@andipohl andipohl commented Jun 1, 2016

I would use persistent connections. But the check with get_resource_type failed because of different strings I get for persistent and non-persistent connections.

  • persistent=false: get_resource_type() == 'SQLAnywhere connection'
  • persistent=true: get_resource_type() == 'SQLAnywhere persistent connection '

buildDSN could not be used for mirrored database installations. Here the host-parameter has to be a list of ip-adresses, comma-separated, e.g. host=ip1:port,ip2:port
other possibility is to leave host blank and use

$driverOptions['links'] = 'tcpip(BROADCAST=YES)'

Please merge this changes.

Andreas Pohl added 2 commits June 1, 2016 16:39
…tion ',

if $persistent=false, resource_type == 'SQLAnywhere connection'
…s case "host=ip1:port,ip2:port"

servername and dbname are optional but can also be used without host parameter
@deeky666
Copy link
Member

@andipohl the issue is valid but you are mixing in charset option support in here which should be a separate PR. Please remove that as well as commented lines. Thanks.

@deeky666
Copy link
Member

Also missing a functional test.

@@ -50,7 +50,7 @@ public function __construct($dsn, $persistent = false)
{
$this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);

if ( ! is_resource($this->connection) || get_resource_type($this->connection) !== 'SQLAnywhere connection') {
if ( ! is_resource($this->connection) || !preg_match('/^SQLAnywhere.*connection.*/',get_resource_type($this->connection)) ) {
Copy link
Member

Choose a reason for hiding this comment

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

You should change this as follows:

$allowedResourceTypes = array(
    'SQLAnywhere connection',
    'SQLAnywhere persistent connection',
);
$resourceType = get_resource_type($this->connection);

if ( ! is_resource($this->connection) || in_array($resourceType, $allowedResourceTypes, true)) {
    // ...
}

Andreas Pohl added 2 commits June 20, 2016 14:31
…. In this case "host=ip1:port,ip2:port" servername and dbname are optional but can also be used without host parameter"

This reverts commit 0698cba.
* removed "charset" patch
* implemeted resource_type compare with in_array instead of regex
* implemented functional tests for connection and statement.
if ( ! is_resource($this->connection) || get_resource_type($this->connection) !== 'SQLAnywhere connection') {
$resourceType = get_resource_type($this->connection);

if ( ! is_resource($this->connection) || !in_array($resourceType, $allowedResourceTypes, true)) {
Copy link
Member

Choose a reason for hiding this comment

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

TBH I think we might safely remove the resource type check at all. We should just leave the is_resource() check, everything else is driver specific implementation detail.

@deeky666 deeky666 added this to the 2.5.5 milestone Jun 29, 2016
@deeky666 deeky666 self-assigned this Jun 29, 2016
Andreas Pohl added 2 commits June 29, 2016 11:11
removed unnecessary  setup/teardown-methods
I am also of the opinion that the resource type checks are unhappy. We depend on driver internals.
@Ocramius
Copy link
Member

Ocramius commented Sep 9, 2016

I'm going to keep far away from persistent connections myself, therefore not merging into 2.5.5 myself. @deeky666 feel free to re-assign a milestone when you checked this in more depth.

@Ocramius Ocramius removed this from the 2.5.5 milestone Sep 9, 2016
@andipohl
Copy link
Author

andipohl commented Jan 9, 2017

What is the reason for not taking the patch in last/next release?

@kimhemsoe
Copy link
Member

@deeky666 is our sqlanywhere guy and dbal maintainer but he is a bit busy these days.

On that node persistent connections sounds very scary in my ears. Do there exist something like mysqlproxy and pgbouncer for sqlanywhere? If yes i would recommend to take a look at those instead.

@deeky666 deeky666 self-requested a review February 9, 2017 23:28
@deeky666 deeky666 added this to the 2.5.13 milestone Feb 9, 2017
@deeky666 deeky666 merged commit dc871b0 into doctrine:master Feb 9, 2017
@deeky666
Copy link
Member

deeky666 commented Feb 9, 2017

@andipohl sorry for the delay but thank you!

@deeky666
Copy link
Member

deeky666 commented Feb 9, 2017

Backported to 2.5 via a2d2162, eff9d44, da64aff, 05c4d3f, 2056171, afcdacf

@morozov
Copy link
Member

morozov commented Feb 10, 2017

Seems like this one introduced build failure on Oracle.

@deeky666
Copy link
Member

Dammit, we need to check for the driver in the setup. I will send a PR. Thanks.

Ocramius added a commit that referenced this pull request Feb 10, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants