On 21/06/2022 02:25, Larry Garfield wrote:
* "Should the sub-classes only be avaiable when support for that DB is compiled in?" - I 
agree, probably not.  Also, "available" is misspelled.

* "Create all DB sub-classes?" - I'd say they all should have subclasses, even if empty.  
It's more consistent that way, and you can then also rely on instanceof giving you useful 
information rather than "well, it's not one of the special ones, so beyond that, NFI."

It's important to remember that PDO drivers are an open set, each provided by their own extension. Like any extension, they can be moved between php-src, PECL, and private repositories. For example, the pdo_sqlsrv driver for SQL Server is provided and actively maintained directly by Microsoft.

I think that goes some way to answering these two questions:

* The sub-classes need to be provided by the individual driver extensions, because ext/pdo itself can't know which drivers might exist, and what methods they might add. So if you don't have a particular driver installed, the class will be undefined, just like anything else provided by an extension.

* The RFC cannot itself promise to create all possible sub-classes. What it can and perhaps should do is mandate that every driver must define such a sub-class as part of whatever registration mechanism is used. (Logically, that implies that all *bundled* extensions would have the sub-class added as part of the RFC's implementation.)


* Re PQescapeIdentifier - My gut thought is that we should have separate 
methods for escaping value and identifier in the base class, and then on most 
DBs they're just identical.  That way it's consistent for anyone building on 
top of it, because they can rely on escapeValue() and escapeIdentifier() always 
being The Right Thing To Do without worrying about which DB they're using.


I agree that it should be a generic feature, but it MUST NOT have any kind of default implementation. The implementation MUST be written by someone with intimate knowledge of the DBMS in question, or it cannot be trusted.

The syntax for identifiers varies a lot between and even within DBMSes. To use SQL Server as an example, because I have it to hand, "a'b", "a''b", and "a\'b" are all different identifiers; but "a""b" and [a"b] are different ways of writing the same thing. Select 1 as 'a' is accepted as valid syntax; but Create Table Foo ( 'a' int ) is not. There are also environment settings that can change some of this behaviour.

So if we only have a Postgres implementation right now, we should either implement quoteIdentifier only on PDOPostgres; or implement it on PDO as throwing a "not implemented" exception, with PDOPostgres currently the only sub-class that over-rides it with a useful implementation.

Regards,

--
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to