Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118033 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99565 invoked from network); 21 Jun 2022 07:52:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Jun 2022 07:52:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C7B7A180548 for ; Tue, 21 Jun 2022 02:41:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 21 Jun 2022 02:41:21 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id z9so7139482wmf.3 for ; Tue, 21 Jun 2022 02:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=QFkRZ4cWQHy7k/nqtrt89WjfH0z3UC49K3+MGdS7yZI=; b=b0oU8tfTG7syfT31ha1BitWZxXO+5sDypf/6ejSkD4qXU+Z6NSXScYoGYImRkLSVqb QYJ56JLB4jSHpOcktQCWezJFTbll0cRNgyH0I3PXJCrlWEG5SUPRHjP6BD/KVVA61HJs PtvdvVwl/ghh3rarwI7p4aENu0K85AmxGdjanZooU6IKQ1uTZHJVMlYOn9xFsUPCqeir JyvX2wJDVc4coFIRvwcocBbUbZzkdP+DlQOhtREjg7zJZVs90Pkdkd8Y+4SwJ/+WoVYx wy5zDYRPcDC5bknZ1pkpfz8sMj6ovdj+PkAaU8LxnWkGDnowiVdMuIN3/7L+oEqo4mc0 Ah0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=QFkRZ4cWQHy7k/nqtrt89WjfH0z3UC49K3+MGdS7yZI=; b=vXWoiHiFpH0x+ceJ3ugey2rocxke6QLS9IeCOQ7bLSdXUY1hObG0daVH2ni6JWZfiM S1hmLjnWYAPEaEHY6+8ZhII/rN/A/iclxPJk6i3uEgb1gyT4ydklBZn9Bh+eeXHpYiny pVI2ZmyGKBaY6jEOKny+UtKCrtu/tI3RiQWi1pwT1gLjeJKkRjE2GOfBigGGU4Ht9j5P A8lbaA0ht22+mg1w7mK0ULReFLumGVsPwrZE0Y+4s2D3+cL9SqWbXLsZ4czo7s8ADXmr I5SPtbrMyNwlBLIrdreVrhT6j1/u848QbbFjTJ3psJM1borBy+iPx8f1nMaNrCqikzyI SzHg== X-Gm-Message-State: AJIora+lBdIW61I6z0XBTEfMXzR4/1kamnj78WHfGGnf4eXEwpKFnUcX MPuX921Yc1PNnmeaDTB7rLsFS4Rn1KQ= X-Google-Smtp-Source: AGRyM1tDfZD8TQ+LlX7lXot6unrWq+m4XDWzJDOpaTDs2AuafcZOMyj6UjUlAQ+79oWl08m3qYrCHQ== X-Received: by 2002:a05:600c:1994:b0:39c:8417:5d8c with SMTP id t20-20020a05600c199400b0039c84175d8cmr29293735wmq.47.1655804480125; Tue, 21 Jun 2022 02:41:20 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id d6-20020adfef86000000b0021b8d1b0568sm6713495wro.52.2022.06.21.02.41.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jun 2022 02:41:19 -0700 (PDT) Message-ID: Date: Tue, 21 Jun 2022 10:41:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-GB To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] [Under Discussion] PDO driver specific sub-classes From: rowan.collins@gmail.com (Rowan Tommins) 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]