Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113314 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71897 invoked from network); 27 Feb 2021 18:50:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Feb 2021 18:50:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3C9A11804D0 for ; Sat, 27 Feb 2021 10:40:30 -0800 (PST) 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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 ; Sat, 27 Feb 2021 10:40:29 -0800 (PST) Received: by mail-wr1-f44.google.com with SMTP id b18so5311721wrn.6 for ; Sat, 27 Feb 2021 10:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=2vgmVwn0wuzKc84zBwsGrooWYD9J9D8v+GWOCkgf3CI=; b=HSSv0/iLgVEkISebAixz0LBGaqgoC2pwCSbSh4FKr4eQrkPdOLB3hh4hLuA75pDgw1 Jf5zMjpcMGiekkX2UWcvSxINYU/6F59OqsUgD9tflYz1Gq17jtBEVLKHseauVbHMMKsA bF0wBM4IMHdBzwY0HQYyLgUTm2/vCUwOa4Xg/RsGKIpt4STsWuG7J/Z5iKhmQ74lBgQT dBbS2Z8qcfi+sTMzabeq5wXOMvlb0LFjXE3g+cRMIImQ3TH6Cm3rvWR6dRiYvtEMxJV6 JogkTRT2GFWTdyO+4L0lLECDHOoOdgkC0Xp48adEVjbvCCXC9E5T/betUCMsXr+EtN8f 0QGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=2vgmVwn0wuzKc84zBwsGrooWYD9J9D8v+GWOCkgf3CI=; b=M5NBkrKrtLhxUc0UPsTTeBfMyYhbGPs9fYHPkERPBEpvg3dfcfo7svcD0b/IHJcqR/ 61YOHsCE8h+zanP2KDsUFgbtFSYD8EJ1rcTKUA5Fk+0YAnqQJ+i4U7PU7oFhSABB1Anv 3WhvDAj+VJk8sN/iWie1PIz5wP1ce/uX9LkFvnH2+uchtrrFX9XFNWQPoFveDj33YtcT ljBsXW2Bw1phniHwizCl+otiGoxqKzzHvFN8EkCENcPTY07ftmnRe3K88CvTMZwq0JRt KyKI/KvIWgNiVJKkN0eezKXpUe/w3sPgvZDZyashwJtZB0MT2xUfj83foRQEvEizyh3e lZGA== X-Gm-Message-State: AOAM531XTGnmIQX6nDtVq7/H0Zgo/TE3y9WmVRaWX/0BRRj1e16mN8DR IKEifusQwFZFXuOrajVooUFZHZMvBVk= X-Google-Smtp-Source: ABdhPJx5gFDfC/ZXZlmcqfBiFeZ7L4cIch+92EiYW25AEkn90vC2ZtcfhwzQZ1kAfxB+k/Er85RwgQ== X-Received: by 2002:a5d:5109:: with SMTP id s9mr9088528wrt.325.1614451228274; Sat, 27 Feb 2021 10:40:28 -0800 (PST) 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 d29sm19040087wra.51.2021.02.27.10.40.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 10:40:27 -0800 (PST) To: PHP internals References: <84a86f15-313e-1fb3-eb09-7fd6bbdeb5ce@php.net> <821813eb972cd5dad30a0e10385a115a9a8908a2.camel@schlueters.de> <2d9e003c-2a05-9cfa-8625-5aedf5b069f6@gmail.com> <445707c1-2b67-1f46-8d93-d9e0ca420b87@gmail.com> Message-ID: Date: Sat, 27 Feb 2021 18:40:25 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC]: Change Default mysqli Error Mode From: rowan.collins@gmail.com (Rowan Tommins) On 27/02/2021 18:10, Kamil Tekiela wrote: > > Select * From products Where product_id = 'hello world' > > If product_id is a column of type int, then the database will raise an > error about incompatible types. > > > No, this query would produce a warning. I am unaware of an SQL mode > that would turn this warning into an error. Right, I forgot we were talking about MySQL, which has the same "ignore and carry on" tradition as PHP; in other DBMSes, that would be an error: PostgreSQL: > ERROR: invalid input syntax for type integer: "hello world" > LINE 1: Select * From products Where product_id = 'hello world'; Microsoft SQL Server: > Msg 245 Level 16 State 1 Line 1 > Conversion failed when converting the varchar value 'hello world' to data type int. However, the main point of the example was to show that an error could go unnoticed, and actually have no immediate negative effects, such that replacing it with an exception makes things worse. > Examples, that would truly be effected are something like this: > > $stmt = $mysqli->query('INSERT INTO tableA (uniqueColumn) > VALUE("repeated value")'); > if (1062 === $mysqli->errno) { >     echo "Can't add this value because it already exists!"; > } > > If the developer didn't silence the errors then the user will see a > generic error instead of the specific one. Precisely, and this is what people are concerned about: if someone is writing code from scratch, exception-by-default is a good thing; but if they have existing error handling, by-passing that handling by throwing an exception is not. Regards, -- Rowan Tommins [IMSoP]