Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71770 invoked from network); 24 Apr 2017 17:46:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2017 17:46:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=adam.baratz@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adambaratz@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.179 as permitted sender) X-PHP-List-Original-Sender: adam.baratz@gmail.com X-Host-Fingerprint: 209.85.216.179 mail-qt0-f179.google.com Received: from [209.85.216.179] ([209.85.216.179:34650] helo=mail-qt0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/43-36901-60A3EF85 for ; Mon, 24 Apr 2017 13:46:46 -0400 Received: by mail-qt0-f179.google.com with SMTP id c45so120144916qtb.1 for ; Mon, 24 Apr 2017 10:46:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ox9OIlK/J+BG8GBUUu2hplrlgiayXF+QIhf4J4j0aKY=; b=MJyMdZHVFGpQuoyK0wQuNpjIcmJg75y/v7zmVoYsUDa2Am2SZqGbxZJr1l7lAN32cH 6iQrFuPxGp0lMIrSdETPgBwXZwHiR1WIYeT26S8WmxEXafW+6p9X9BcekzMqZSa3R9rk u6SwjjxkSDFT3rCBwO1xfQic/P4LdBcOvqF+qP/araztCDlUQIp/xilewolOrjD9R5kk ynsI9eDNw+lq82VmLRc6vvWyaeF9L1kVvQjEDwAX9dAZdXpl8uV8lPEFcH1jGwA+OHCe Pn4JmUMYR/tvss559XKoXr/f2jj1bnN8oyha3Juy0PEafVfaVQJCyQoqvcHyo3yve1JA CfbQ== X-Gm-Message-State: AN3rC/6rOiQsum6vHdWLLbQaU1zWYoNFEhfVCsoBMh81gzKQ+mNR3ILa e1RGlaEKA7pK3lZpggg= X-Received: by 10.237.49.161 with SMTP id 30mr29155391qth.53.1493056003946; Mon, 24 Apr 2017 10:46:43 -0700 (PDT) Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com. [209.85.220.181]) by smtp.gmail.com with ESMTPSA id y201sm7661077qky.41.2017.04.24.10.46.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2017 10:46:43 -0700 (PDT) Received: by mail-qk0-f181.google.com with SMTP id u75so27013047qka.3 for ; Mon, 24 Apr 2017 10:46:43 -0700 (PDT) X-Received: by 10.55.15.143 with SMTP id 15mr20786599qkp.44.1493056002943; Mon, 24 Apr 2017 10:46:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.135.212 with HTTP; Mon, 24 Apr 2017 10:46:42 -0700 (PDT) In-Reply-To: <36b72547-db1d-125b-62e4-bb3290972dbd@beccati.com> References: <5e3e3e9b-f5b9-a19e-c4cb-6af0f5985d94@beccati.com> <8923084a-a357-91e9-44b5-52a4af0a5df1@beccati.com> <86e4681f-9030-80fc-896b-56255c4b84c7@beccati.com> <36b72547-db1d-125b-62e4-bb3290972dbd@beccati.com> Date: Mon, 24 Apr 2017 13:46:42 -0400 X-Gmail-Original-Message-ID: Message-ID: To: Matteo Beccati Cc: "internals@lists.php.net" , Andrea Faulds Content-Type: multipart/alternative; boundary=001a1146cc10af745d054ded30c4 Subject: Re: [PHP-DEV] [RFC] PDO Float Type From: adambaratz@php.net (Adam Baratz) --001a1146cc10af745d054ded30c4 Content-Type: text/plain; charset=UTF-8 > > On 20/04/2017 00:51, Adam Baratz wrote: > > The reason I went that way was I couldn't find a DB API that > > differentiates between the two types. They all represent them as a > > double, so it seemed like a needless distinction to create two PDO > > types, especially when PHP floats are the only built-in type for these > > numbers. Creating a dependency between bcmath and pdo (or something > > similar) feels awkward because it would offer false guarantees about > > what gets communicated to the DB server. > > Sorry, your research wasn't probably as accurate as you think. Certainly > libpq doesn't do that and, from what I gather, mysql doesn't either, > according to what I read in: > I think we're talking about different things. I'm talking about binding parameters. It seems like you're talking about fetching column data. You are correct that fixed-precision values are typically fetched as strings. One thing to note is that this can be a choice made by the PDO driver extension. With libpq, PQgetvalue[1] returns all column data as strings. If you look at pgsql_stmt_get_col, you'll see extra logic to cast to a zend_bool or zend_long. Other drivers, like pdo_odbc, fetch everything as a string. If some database APIs aren't capable of properly handling fixed > precision, it is their fault (dblib?, firebird?), but PDO shouldn't > behave like the less capable ones. > I wrote in the RFC how each API works. They all lack this ability, because they're all limited by the C type system. This is why I was arguing to merge floats and fixed-precision types. It's a difference that doesn't exist when sending data to the database. I'll admit I wasn't paying a lot of attention to retrieving data. There's a lot of variability between PDO drivers and I didn't want to complicate the scope of the RFC. If I can summarize our underlying arguments, mine is that PDO parameters should correspond to zval types and C types, yours is that PDO parameters should correspond to database column types. A lot of PDO internals tend to assume the former, even if the latter is the conventional wisdom. Honestly, I'm not very attached to having a single type for floats and fixed-precision. If this RFC doesn't pass, which it doesn't look like it will, I would be just as happy to cut fixed-precision values out of it. Though I don't have a good handle on how many of the people who voted "no" would change their minds if fixed-precision was simply left out of scope. Thanks, Adam --- [1] https://www.postgresql.org/docs/9.6/static/libpq-exec.ht ml#LIBPQ-PQGETVALUE --001a1146cc10af745d054ded30c4--