Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130545 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id DA8F11A00BC for ; Fri, 3 Apr 2026 15:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1775230160; bh=l3IuhJUhrgvDNHlhMAXkDJ2Y32Vn/yzSXh4Ke3X+cN4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DG9q028w8NrWVB8FmDKAs84XlrOO6iWn6JmFG3tVD4COsdiKoxi61uP/VxbF2apFj Yx4frBVvP61849vK/26kmI2u3zjglSkH4OoTvAzScc9NT3XRqeTEm+a8UjtPkqQSOz sVARqhH9bnJTMCglJhA7DYio6w45scwrvDBPCplu1O1/UaXySI4KyIx3/P6YZo9uHj jbd74L7KTxqwVutpnKcKn0cCtpYrWGcPn10SVF7pZYGTBYeDSoAJf7zQtAg081Fa/m ljXIkPFcUqk4Zb/ULbxD6FSjOAhHJBoOGaew6GvyXCTxh38/fktQ1dgO4GAME5g7DM w1Joa+bXWG7Qg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C274180062 for ; Fri, 3 Apr 2026 15:29:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 3 Apr 2026 15:29:18 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43b9d3ebed5so1918137f8f.1 for ; Fri, 03 Apr 2026 08:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775230152; cv=none; d=google.com; s=arc-20240605; b=e9OJm2oISPKvtH45zJzudz/MfgXzbu0y6IhrHLCXX1cNiqnYybGncan0IDSnA/kTTJ L1cWkJuNKTrBeoOwQ0JqDeHLjmEo0VZGDYWA9EkVTvS6bk62bamglxNhrWRUKptKWWbt ZKbIUVjKU2Oi1hOFSKfXD1n2M7EQoUDQf+TTLVypQu/WNf1I/xO9NhYSvQSY/hQEkYNy rSgGxn3kLoQaSkrHxjI5/yA9n/VRpyA3K15E25cnmOXnqZZtp+iRDOLm6DtG0WLwbjKY KL4zkiMO+jIsfAkWkIu8O+0Ytzm+W61u6FKviMIwSLjSjQIGepbg8q0FT9BNFnytLNSh ld9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=mDdiCBSQkQvXFwhh1vHPaDcjKejmn+ZJYtCOodXl3iA=; fh=TxbkRDLnz5ng31q/zdSXdA5aavfWeZozqwPd/DA1odk=; b=GPZ2hvSLsE5yu6egQ/S6B0/+YDOrfY62pORrnNFktGTXMbCeFZcxTKDg6oRT9MrYlD ue9u04its9lHThfCViKZx+xVgyntoiqd3nCdI9dz4aTcihbsIyaChaMwW4R1XABf6+nG hDhwXoPx0jFeZNrm0VvlqqdcOOTAEz6xrl8DUhRtneMQWBx/49ANOau7DuyhQwUYYKPb 0QA137CND2TBedlyKwiMqnB1r7ZxCy/riIjly/PGZvDAsFFtdef263DzN2Fi0sXcPNeC ukqIUdvXQzFl54ugMqTAF0/ieRTzOkWY9abJFWbVgWV9o4mcu7XvblYfqDlvdfx6A8yR qMSA==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilia.ws; s=google; t=1775230152; x=1775834952; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mDdiCBSQkQvXFwhh1vHPaDcjKejmn+ZJYtCOodXl3iA=; b=ASxe+KzNGnZeKknc7p4Yy8xE6xSpO9dMpGgaj8aKbk9IMi7PA0aZFfrQ3Wg048xVX6 Uftq794JA8AtapFTjluD0Ge513AABwKJfcpPbuLQAjuaC7LU0vJhlxE7In06L5lTDTUS 3xMSZEkNwHgj+wsa+P+sZfcx7it6TmAcgKBVtZbNUEwxSvchTm1CjfvDc85ys6TuUmM7 n/T+LAUa6p54c9mTUFS/9tqXWVxePRdOdAtxPyYvlByQ/5VhCZJnu9optI/+YuwQy7Xb OVnn6lZT9TqnX9il96O/yGzc7ohtpAsgauPaRWmFNX5B91SuM9QYIvTFtuP64GBdyg9M chcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775230152; x=1775834952; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mDdiCBSQkQvXFwhh1vHPaDcjKejmn+ZJYtCOodXl3iA=; b=XNi9IXgqXgQmUf8jd1D2CaEJqXuibagF1/3LV+eQnKgBxUhkEBBCSqkKs9N83iIufp XY63kJy+j8c83ro1pfFrBh5+o6KxITmx9GT5i11ghtMDkWyb3NrTY+3yjaPmqvgGvHms KLB39KQ1xrmNhOltGjUnxk3JQ8fzb6T39/51M7W1ps2f7lLs4Eu6pcYb+cZ8FWd7+hBu 4kLct9mfsXl4D0OjbhnjY/0lN0uydpYQzLjJuQ1Kbz+rdE5qRyi+6xsNLJhQjNuqJkfw mdob+xX3rTt2XItKiPskZ0uODsW7Cd0VQsv/2xu1JUhmSh8L+euznwWo6LK3evU69iCW Y+yw== X-Gm-Message-State: AOJu0YzIbpHhIkgOe+jK8/OmWxtoJmZP52JFDoCy+pN7NsHUWLgM/hTc CyVAVK8Yjp5LhjVLwsActuvKx6EhH82bk+m+pkwhjW6cUowpKdHrSeFU2syoVW3LZeeDbshufHj sKSUXnG1mpOOSJdeKB0c11bpsS/t1L+6Y6mlq9wU097crWHwetdU= X-Gm-Gg: AeBDietCQfc+v8cBqqkI2cdjWLaHgeZq5JeNzhhrFtEXv9RS7YfTTiMmsY288xi7NOp cyK7wZYCKg63Iw/btJjFqyIqD0Yr/LlZqNVU8AsfY/3ntL+rEVeBpGB7qJGmqI9ifN6dD+qmDRX EPWGX6xfKJ1dCUk9tFFQ+WQSUFUkmy+5HllmGEwii1LhKfFPJ9QJSt1bMLNfld5hFkFpWOXFuIs C2jc7ZHMO9giK9YYfBhaBTODMr3+zS6Q6GAPWco2VJLtqlvkLfpnnNwv6cYAOva8OwaOzpIpOlX oi7au44AN4uBNx5RZkJkgfRvOTsYTdPhZM7dUuob8w5PkSDCzhu+bYEDYTtv8Ye8odg/ X-Received: by 2002:a05:6000:2489:b0:43c:ff3f:c635 with SMTP id ffacd0b85a97d-43d292db150mr5346441f8f.34.1775230152329; Fri, 03 Apr 2026 08:29:12 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Apr 2026 11:29:01 -0400 X-Gm-Features: AQROBzC1D_GhBQ3JtGC0KYeIqtDFlIbNC498JI-9J2xctEXM-sQBxca465DBTvo Message-ID: Subject: Re: [PHP-DEV] PDO SQLite: statement attributes for SQL text retrieval To: Kamil Tekiela Cc: PHP Developers Mailing List , saki@php.net Content-Type: multipart/alternative; boundary="0000000000009fddfd064e8ffafe" From: ilia@ilia.ws (Ilia) --0000000000009fddfd064e8ffafe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable In the context of the SQLite extension, this makes 100% sense as a separate function. In the context of PDO which tries to be generic when fetching essentially meta-data IMO it makes more sense to fetch via the attribute framework which is generic as opposed to creating driver-specific functions. In terms of utility this primarily be helpful for debugging / analysis purposes and completes the driver implementation, making what PDO offers match what the native extension offers. It doesn't impact performance etc... so no negative effect that I can see On Fri, Apr 3, 2026 at 11:21=E2=80=AFAM Kamil Tekiela wrote: > On Fri, 3 Apr 2026 at 13:29, Ilia wrote: > > > > Hi internals, > > > > I'm looking for feedback on a small pdo_sqlite addition. > > > > PR: https://github.com/php/php-src/pull/21456 > > Implements: https://github.com/php/php-src/issues/21322 > > > > Two new read-only statement attributes on Pdo\Sqlite: > > - Pdo\Sqlite::ATTR_SQL =E2=80=94 original SQL text of a prepared statem= ent (via > sqlite3_sql()) > > - Pdo\Sqlite::ATTR_EXPANDED_SQL =E2=80=94 SQL with bound parameters inl= ined (via > sqlite3_expanded_sql()) > > > > $stmt =3D $db->prepare('SELECT :name AS greeting'); > > $stmt->bindValue(':name', 'hello'); > > $stmt->execute(); > > > > $stmt->getAttribute(Pdo\Sqlite::ATTR_SQL); // "SELECT :name AS > greeting" > > $stmt->getAttribute(Pdo\Sqlite::ATTR_EXPANDED_SQL); // "SELECT 'hello' > AS greeting" > > > > This mirrors SQLite3Stmt::getSQL() from the non-PDO API, but uses PDO's > getAttribute() mechanism rather than adding a driver-specific method. The > attribute system is how PDO drivers expose driver-specific functionality, > so it's a natural fit. > > > > ATTR_EXPANDED_SQL is gated behind a configure check for > sqlite3_expanded_sql availability. > > > > I don't think this needs a full RFC given the scope (two read-only > attributes, single driver, no BC impact), but I wanted input from the lis= t. > > > > Thoughts? > > > > -- > > Ilia Alshanetsky > > Technologist, CTO, Entrepreneur > > E: ilia@ilia.ws > > T: @iliaa > > B: http://ilia.ws > > I agree with Saki that a dedicated function would be better than > treating this as an attribute. However, I fail to understand why this > is useful at all. SQL is something that is coming from the developer > using the function, so why would they need to look it up again from > the prepared statement? The emulated statement could be useful in case > an error is triggered due to a data issue, but not only does this > happen rarely, but the error already contains all the necessary > information. I think I would like to see a concrete use case of when > this is helpful. > --=20 Ilia Alshanetsky Technologist, CTO, Entrepreneur E: ilia@ilia.ws T: @iliaa B: http://ilia.ws --0000000000009fddfd064e8ffafe Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In the context of the SQLite extension, t= his makes 100% sense as a separate function. In the context of PDO which tr= ies to be generic when=C2=A0fetching essentially meta-data IMO it makes mor= e sense to fetch via the attribute framework which is generic as opposed to= creating driver-specific functions.=C2=A0

=
In terms of utility this primarily be helpful for debugging / analysis= purposes and completes the driver implementation, making what PDO offers m= atch what the native extension offers. It doesn't impact performance et= c... so no negative effect that I can see

On Fri, Apr = 3, 2026 at 11:21=E2=80=AFAM Kamil Tekiela <tekiela246@gmail.com> wrote:
On Fri, 3 Apr 2026 at 13:29, Ilia <ilia@ilia.ws> wrote: >
> Hi internals,
>
> I'm looking for feedback on a small pdo_sqlite addition.
>
> PR: https://github.com/php/php-src/pull/21456
> Implements: https://github.com/php/php-src/issues/21= 322
>
> Two new read-only statement attributes on Pdo\Sqlite:
> - Pdo\Sqlite::ATTR_SQL =E2=80=94 original SQL text of a prepared state= ment (via sqlite3_sql())
> - Pdo\Sqlite::ATTR_EXPANDED_SQL =E2=80=94 SQL with bound parameters in= lined (via sqlite3_expanded_sql())
>
> $stmt =3D $db->prepare('SELECT :name AS greeting');
> $stmt->bindValue(':name', 'hello');
> $stmt->execute();
>
> $stmt->getAttribute(Pdo\Sqlite::ATTR_SQL);=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 // "SELECT :name AS greeting"
> $stmt->getAttribute(Pdo\Sqlite::ATTR_EXPANDED_SQL); // "SELECT= 'hello' AS greeting"
>
> This mirrors SQLite3Stmt::getSQL() from the non-PDO API, but uses PDO&= #39;s getAttribute() mechanism rather than adding a driver-specific method.= The attribute system is how PDO drivers expose driver-specific functionali= ty, so it's a natural fit.
>
> ATTR_EXPANDED_SQL is gated behind a configure check for sqlite3_expand= ed_sql availability.
>
> I don't think this needs a full RFC given the scope (two read-only= attributes, single driver, no BC impact), but I wanted input from the list= .
>
> Thoughts?
>
> --
> Ilia Alshanetsky
> Technologist, CTO, Entrepreneur
> E: ilia@ilia.ws<= br> > T: @iliaa
> B: htt= p://ilia.ws

I agree with Saki that a dedicated function would be better than
treating this as an attribute. However, I fail to understand why this
is useful at all. SQL is something that is coming from the developer
using the function, so why would they need to look it up again from
the prepared statement? The emulated statement could be useful in case
an error is triggered due to a data issue, but not only does this
happen rarely, but the error already contains all the necessary
information. I think I would like to see a concrete use case of when
this is helpful.


--
Ilia Alshanetsky
Technologist, CTO, Entrepre= neur
T: @iliaa=C2=A0
--0000000000009fddfd064e8ffafe--