Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113521 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66775 invoked from network); 14 Mar 2021 20:25:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2021 20:25:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 09FD11804D1 for ; Sun, 14 Mar 2021 13:19:08 -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=0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RAZOR2_CF_RANGE_51_100,RAZOR2_CHECK,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 14 Mar 2021 13:19:07 -0700 (PDT) Received: by mail-ot1-f54.google.com with SMTP id h6-20020a0568300346b02901b71a850ab4so4131706ote.6 for ; Sun, 14 Mar 2021 13:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=zdZwVCPCdXDuYyFXt/Bvd4r1dwj+HPvEpNMJtwMeh5M=; b=MbbLzRSootdExG1XmBUdT3SK5hP24lWLkbI7f+AIMALS6DLrY8SyW/f+4OEb206q8D m0ubic/AORLVXq0T4NocwBQcHQwAe8w6c9rZ7eVYpO+VVXr9/rif1rPuAY2DUy7LLUSq pP95KngFf3UOsG+kK/QHlADR6Y7SPRaFIeOezXshjRx09CVKinKQFmP3bbs+qh+er5DV W43F4e55kSnAodwIhvbinDeXHQqNhSThUFhnXpEWqQsCUgOfxNnns69nhoARAXB/DtsI IXuQdDMIm0TTioBMbeKUp0xAJjrZsnp5kyFo6oC5OM3TEByO8hhJIUJ/ykyxOqX0W4Oy I4cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=zdZwVCPCdXDuYyFXt/Bvd4r1dwj+HPvEpNMJtwMeh5M=; b=j0iTd4HG4XLIbEQAQDLK6qSTEpw4SS9WN4FLy7GFkWnWElrberEAFpaxvfWx0SBWMR 9uQHTG2PkLCqfF/sNfUkMYDcWfO49chH3wVcHNxzcN4KAm7oJETmB44ZM3LYDP5A2F9j PjeU8OfxXt4knBn+EdpXpVPa6wCRMbrM5k4ISqSOnU7/XcUGRTNC+nU9cqAd08/A3wCH ef/ZXqmkd6B60bc3OU0kXygOcFXQHmW46tG7fyWIrT8mlhj2didEdaTp5RwquONMFFgy YzaOuSnJoI6HEOowoi4kvfQ/o+4/yTC4N0z+UoIY5d4OLPLCysoLj3OQIiQ04Kq+xLxJ L29w== X-Gm-Message-State: AOAM533fVsry4XL77DB2UQkoaX1OP6cutv52oLcujmqv1Pzaw46BPa6I WCvz4aYhL+WjTmT1lgiZI8v5i+S9niRKzGlWzfflxLQA0ekJ5w== X-Google-Smtp-Source: ABdhPJz1IUnZmrCVGVxZrtxKAA74uPQOJb7GgMGPX35k8ORbBzNbY1lMeP2P67y4BdS9KiyJ4Y+QjQZKyCqEgQXYuY8= X-Received: by 2002:a9d:74cc:: with SMTP id a12mr11513868otl.135.1615753144308; Sun, 14 Mar 2021 13:19:04 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 14 Mar 2021 21:18:53 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="00000000000036155305bd84d89c" Subject: PDO::PARAM_INT and pgsql driver From: benjamin.morel@gmail.com (Benjamin Morel) --00000000000036155305bd84d89c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi internals, I just stumbled upon what I consider to be a bug with the PDO pgsql driver. *TL;DR: the driver treats parameters bound with PARAM_INT the same as PARAM_STR.* Take the following example: ``` $pdo =3D new PDO('pgsql:host=3Dlocalhost;port=3D5432', 'postgres', 'postgre= s'); $statement =3D $pdo->prepare(" SELECT ST_AsText( ST_Transform( ST_GeomFromText('POINT(0 0)', 2154), ? ) ) "); $statement->bindValue(1, 4326, PDO::PARAM_INT); $statement->execute(); ``` This fails with the following message: PDOException: SQLSTATE[XX000]: Internal error: 7 ERROR: could not parse > proj string '4326' This is because the pgsql driver seems to treat everything as PARAM_STR, despite being explicitly requested to bind the value as PARAM_INT; the placeholder is therefore replaced with the string '4326' instead of the integer 4326. The problem is, in PostGIS, the ST_Transform() function has different signatures with different behaviours depending on whether the second parameter is an integer or a string. As far as I can see, because of this issue, *there is no way to pass an actual integer to ST_Transform()*, which forces me to use PostgreSQL-specific cast syntax to get the behaviour I need, in a library I maintain that's supposed to work with any GIS-enabled database. Is there any reason why the pgsql driver doesn't respect PDO::PARAM_STR? I asked this question on StackOverflow , and was pointed to the following bug, which I'm not sure is directly related, but was closed as "not a bug": https://bugs.php.net/bug.php?id=3D50206 *Should this be requalified as a bug and be fixed?* Thanks in advance for your consideration, =E2=80=94 Benjamin --00000000000036155305bd84d89c--