Re: Re: PHP PDO comment on IRC

From: Date: Wed, 15 Apr 2009 23:25:44 +0000
Subject: Re: Re: PHP PDO comment on IRC
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-43716@lists.php.net to get a copy of this message
Christopher Jones wrote: > Matteo Beccati wrote: >> Here's a proposal: >> http://www.beccati.com/misc/php/pdo_streams_v4.diff >> >> The idea is to add a new #define PDO_DRIVER_API_CHECK which is verified >> at compile time by the C preprocessor. If its value doesn't match the >> main PDO_DRIVER_API an #error is triggered, e.g: >> >> In file included from /tmp/PDO_PGSQL-1.0.2/pdo_pgsql.c:29: >> /usr/local/include/php/ext/pdo/php_pdo_driver.h:50:2: error: #error "PDO >> driver not compatible with the PDO API version in use" > > Hi Matteo, > > I'll just comment on the internal API versioning part - let's get that > sorted out first. > > To make it easier to write database specific PDO drivers that work > with a range of versions of the internal PDO API, I think > PDO_DRIVER_API_CHECK could be changed to be min & max values that the > driver supports. The check would be: > > #if !defined(PDO_DRIVER_API_IMPLEMENTED_MIN) || \ > !defined(PDO_DRIVER_API_IMPLEMENTED_MAX) || \ > !(PDO_DRIVER_API_IMPLEMENTED_MIN <= PDO_DRIVER_API && \ > PDO_DRIVER_API <= PDO_DRIVER_API_IMPLEMENTED_MAX) > #error "PDO driver not compatible with the PDO API version in use" > #endif > > Adding code documentation to the macros explaining what driver writers > can & should do would be useful (i.e. please add some). > > I'm not keen on the introduction of php_pdo_version.h. It seems a > kludge so that PDO passes its own version check. It makes PDO itself > defines the same value in two places. If you're going to bump > PDO_DRIVER_API and change the API, thus making all current PDO drivers > incompatible, you may as well continue making changes. Perhaps put > the version check code in a new file that is only included in DB > driver files, and not in PDO .c files. Updated patch available at: http://www.beccati.com/misc/php/pdo_streams_v5.diff with MIN/MAX, a bit more documentation and replaced php_pdo_version.h with php_pdo_main.h which defines proper MIN/MAX constant for the extension. I've also posted to pecl-dev and pdo mailing lists asking for feedback from the driver mainteiners. Cheers -- Matteo Beccati OpenX - http://www.openx.org

« previous php.internals (#43716) next »