Re: PHP PDO comment on IRC
| From: | Matteo Beccati | Date: | Sat, 11 Apr 2009 02:15:45 +0000 |
| Subject: | Re: PHP PDO comment on IRC | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43663@lists.php.net to get a copy of this message | ||
Hi Chris,
Cc-ing Internals
> In case you don't log IRC chats, below are some comments from today.
> The intent is to prevent externally maintained PDO drivers (e.g. IBM's)
> from being used with PDO unless they have been updated to any
> new API changes.
>
> I believe simply updating PDO_DRIVER_API is not sufficient.
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"
That said, being able to change a function signature made it very easy
to cleanly fix the bug I was trying to squash (i.e. PDO not able to
distinguish between stream and empty string LOBs returned by the driver
because both have 0 as len parameter).
As a result PDO now now returns all LOBs as streams, unless instructed
to do otherwise (STRINGIFY). Previously only non-empty LOBs were
streams: I know that the change breaks BC but seems more consistent to
me. If it's not desirable most likely I'd need some help with streams...
IRC conversation excerpt follows:
> ----------------
>
> cjorcl: Spritz, johannes_ the pdo api version for PDO_DRIVER_API check
> seems to be a binary runtime check. The macro is only defined
> in PDO and is used in all drivers built against that PDO code.
> This doesn't guarantee the driver code was designed for that
> PDO API. Perhaps pdo_driver_t can have a field added at the
> end. Each driver would need to set this to a driver-specific
> hard coded value equal to the value of PDO_DRIVER_API. Then
> php_pdo_register_driver could verify the value matches the API
> version. This is still a runtime check, but stops any
> externally maintained driver from being used. Also a compile
> time check could be added to drivers under the control of the
> PHP community.
>
> johannes_: cjorcl: jut make sure that API changes are backwards
> compatible or break compiling :-p
>
> cjorcl: johannes_, that's why the pdo_driver_t field would beed to be
> added at the end fo the struct
>
> johannes_: and making it part of the structure is bad if you have lot
> of additions not breaking BC, it wuld have to be a callback
> function
>
> cjorcl: johannes_, adding a register time callback is a bigger task -
> but would break compilation compatibility nicely for
> non-updated drivers
>
>
Cheers
--
Matteo Beccati
OpenX - http://www.openx.org