php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22986 Unhappily 'conection cache' handling
Submitted: 2003-03-31 11:51 UTC Modified: 2020-09-29 09:21 UTC
Votes:3
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ray at unreal64 dot net Assigned: cmb (profile)
Status: Closed Package: ODBC related
PHP Version: 4.x OS: Windows NT4.0
Private report: No CVE-ID: None
 [2003-03-31 11:51 UTC] ray at unreal64 dot net
Hi !

ODBC function "odbc_do_connect" caches connection. It setup "hashed_details" variable and tries to reuse physical DB connection if new PHP connection is being created.

It brings BIG problem while creating more complicated things. Imagine, you have some long server side action over database running in transaction (allready get point ? :) Thin client need to show procedure progress. Details are not important, but client 'shows' progress bar. So, inside 'big' server side action, need to be updated 'progress' table which is used by another HTTP request to show real progress to user (action can take tenths seconds).

So, if I need to open 2 separate connections, I am in the trouble. Ofcourse, the same user, the same password, the same cursor type. I think it is ugly to create separate user do to this :) [even it is temporary solcution ofcourse]

So, I suggest to add parameter to PHP's odbc_connect/pconnect - something like "I am not soo stupid as I look and I really need 2 connections" or add 'flag' to 'cursor type' (and declare this last parameter as 'connection flags' rather 'cursor type') - something like SQL_FLG_NO_CONN_CACHE.

Would be nice feature :) If it is 'someway' possible, please, let me know. I didn't find how.

Thank you,
Have a niceday
Ray

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-31 11:57 UTC] why at email dot address dot com
Pgsql solves this trouble by 'connection flags' and PGSQL_CONNECT_FORCE_NEW.
 [2003-04-24 01:16 UTC] ray at unreal64 dot net
I didn't try binaries, but I looked on current sources and checked changes on ODBC files.

I didn't find anything in php_odbc.c (odbc_do_connect) which solves cache problem. I expected adding connection 'flag' or 'odbc_connect_nocache' or something. 

Still there is 'connection' handling which setups hash array and ALWAYS search array and reuse connections. It causes problems with transactions and more physical connections.

Let me know, if I missed something :)

R.
 [2003-05-18 22:30 UTC] kalowsky@php.net
Yes yes, this is on my TODO list.  In fact it's kind of working already, I just haven't commited any code.  Moving this from a bug to a feature request, because it's not really a bug.

You are correct though that you can change the password/user to get around this, but an even easier solution is to change the cursor type.  
 [2003-05-18 22:31 UTC] kalowsky@php.net
Updating the verison since this effects ALL PHP4 installations.  Hopefully this won't be the case with 5 if I can get things done :)
 [2010-11-18 23:08 UTC] jani@php.net
-Package: Feature/Change Request +Package: ODBC related -PHP Version: PHP v4.x +PHP Version: 4.x
 [2017-10-24 02:21 UTC] kalle@php.net
-Status: Open +Status: Analyzed -Type: Feature/Change Request +Type: Bug
 [2017-10-24 02:21 UTC] kalle@php.net
I would argue that this is more a bug, gonna re-classify it as such as by looking at the code of ext/odbc it still seems to be present today
 [2020-06-24 11:11 UTC] cmb@php.net
I agree that trying to re-use a persistent connection even though
`odbc_connect()` is called is more like a bug.  However, changing
that in a stable PHP version may cause a BC break (some setups may
rely on the behavior).

Furthermore, persistent ODBC connections may not be the best idea
at all, if the system supports ODBC connection pooling; a
respective note for PDO ODBC[1] also applies to ext/odbc.

[1] <https://www.php.net/manual/en/pdo.connections.php>
 [2020-09-27 19:21 UTC] cmb@php.net
> […], if the system supports ODBC connection pooling; a
> respective note for PDO ODBC[1] also applies to ext/odbc.

No, ext/odbc does not support ODBC connection pooling at all.
 [2020-09-27 21:20 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #22986: odbc_connect() may reuse persistent connection
On GitHub:  https://github.com/php/php-src/pull/6223
Patch:      https://github.com/php/php-src/pull/6223.patch
 [2020-09-29 09:20 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9f5a77188c71bada8175dc48dd20847760bb7b10
Log: Fix #22986: odbc_connect() may reuse persistent connection
 [2020-09-29 09:20 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2020-09-29 09:21 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC