[DBAL-507] [GH-313] Enhanced Master-Slave Connection Created: 26/Apr/13  Updated: 27/Apr/13  Resolved: 27/Apr/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of andrejhudec:

Url: https://github.com/doctrine/dbal/pull/313

Message:

Q A
-------------
Bug fix? no
New feature? yes
BC breaks? no?
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT

Current implementation of MasterSlaveConnection is very restrictive. The slave is picked up only when `executeQuery` is used. If appliacation uses `prepare` method in queries, every `SELECT` is done on master and this is bad for performance of master.

This PR changes how and when it picks the slave or master:

1. Slave if master was never picked before and ONLY if `getWrappedConnection`, `query`, `prepare`, or `executeQuery` is used and the query begins with `SELECT` (case insensitive) string.

2. Master picked when `exec`, `executeUpdate`, `insert`, `delete`, `update`, `createSavepoint`, `releaseSavepoint`, `beginTransaction`, `rollback`, `commit` is called.

3. Master picked when `query`, `prepare` or `executeQuery` is called and the query doesn't begin with `SELECT` (case insensitive) string.

4. If master was picked once during the lifetime of the connection it will always get picked afterwards.

5. One slave connection is randomly picked ONCE during a request.



 Comments   
Comment by Doctrine Bot [ 27/Apr/13 ]

A related Github Pull-Request [GH-313] was closed:
https://github.com/doctrine/dbal/pull/313

Generated at Tue Sep 02 07:11:06 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.