Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLw23-0004Ay-Vs for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Mar 2021 22:49:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLw22-0004BO-Tx for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Mar 2021 22:49:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLw22-0004BD-J0 for pgsql-hackers@lists.postgresql.org; Mon, 15 Mar 2021 22:49:50 +0000 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lLw1z-0003Lh-QE for pgsql-hackers@postgresql.org; Mon, 15 Mar 2021 22:49:49 +0000 Received: by mail-io1-xd33.google.com with SMTP id g27so35204275iox.2 for ; Mon, 15 Mar 2021 15:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fqBRbvMjaLwL1foofh1dKNQxdEUljsbS6qfif9PkGoA=; b=bzx9LYtHoVQly6qmYKAOlIdolL++G44EUZa45TadI7s8ADxwkp/GsDktLyVwv2jYNU MKgionChl0z/Etw2NLlcP1m8/y8R1IZxPXP8ZQ6C+IyU5p1fKYUBBGJl3eIGMt1OdTwt ZrVqR7C+lKEfXqwjifdup6ySVSoHxw2pS0gn9gnrfPhtar9i+Y4oMloETT/n9kgVuYJN LVWiD51e/cCJ0mGCUiFsdg/NfNP5MEBQvJu8JHDKCNNX8nXtflZBqSl5kSNQ+lhPm9b4 8nr/NyJE/GT1GJdlkyhBtjnvkophMUch5x7pbeyC4uWCOUiV5eaUdBSf3ZlS4dAqigr1 gCxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fqBRbvMjaLwL1foofh1dKNQxdEUljsbS6qfif9PkGoA=; b=A+7lpnZ80mL/GX1nIJTcIJ+yq5wX4CMI+bLzqV+VnjNh5noWg9uKg/uKf4sR/Ew5NF UqO5LTYdbqtUkzwbfPx1epNrj6UHa1ggYFrMy2NoCS0QmePEaxCYUB8MLmwxKpdp/0U2 obHn+uQQJGGY/aaqH9R6knHWGQvlZsxb1jkh+dp6JHM5mjOWKQO1oc/Tq070YybFmpyJ XDa3kPmTie61Uy34QWq7BoakMHM8DDLJrOrXSql7VyRHXrDfUKmT0qghO6ZkzMsKaWYT rb5irmiiVnpBzgeY066JG5H5XLbAjBgI3o0Oqyoh1PZed/tk7+Y3K9IpAs6gMWQBpYl7 NOnQ== X-Gm-Message-State: AOAM532bti2K2prjvZylMJFvUU3eFGdBXzapG2fEu8jyT3jRuAeqwwSr JKHQVyoNFDjuZ3aD1CkF39bwOA== X-Google-Smtp-Source: ABdhPJwUoBQ47o3KAJ4ZOfsXSs6d+f/n5CvWF8aNSldiYahbOmSMOPZCQmZ8gwikVPDomaLOl4xmHg== X-Received: by 2002:a05:6638:43:: with SMTP id a3mr11103432jap.102.1615848586821; Mon, 15 Mar 2021 15:49:46 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x17sm8551164ilm.40.2021.03.15.15.49.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Mar 2021 15:49:46 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5C715800925; Mon, 15 Mar 2021 17:49:45 -0500 (CDT) Date: Mon, 15 Mar 2021 17:49:45 -0500 From: Justin Pryzby To: Tom Lane Cc: Alvaro Herrera , Alexey Bashtanov , Franck Verrot , pgsql-hackers@postgresql.org Subject: Re: [PATCH]: Allow errors in parameter values to be reported during the BIND phase itself.. Message-ID: <20210315224945.GB29463@telsasoft.com> References: <20210104170939.GH9712@telsasoft.com> <3087634.1615848349@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3087634.1615848349@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 15, 2021 at 06:45:49PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > For example: > > $ python3.5 -c "import pg; db=pg.DB(); q = db.query(\"SET log_parameter_max_length_on_error=-1;\"); db.prepare('p', 'SELECT \$1::smallint'); db.query_prepared('p',66666);" > > 2021-01-03 02:21:04.547 CST [20157] ERROR: value "66666" is out of range for type smallint > > 2021-01-03 02:21:04.547 CST [20157] CONTEXT: unnamed portal with parameters: $1 = '66666' > > 2021-01-03 02:21:04.547 CST [20157] STATEMENT: SELECT $1::smallint > > > When there are many bind params, this can be useful to determine which is out > > of range. Think 900 int/smallint columns, or less-wide tables being inserted > > multiple rows at a time with VALUES(),(),()... > > > Of course, this isn't as good as showing the column name, so I might pursue > > Tom's suggestion for that at some point. > > I started to look at this, and immediately began to wonder where is the > previous discussion you're evidently referring to. Can you dig up an > archives link? I think I was referring to this (from the commit message). https://www.postgresql.org/message-id/flat/CANfkH5k-6nNt-4cSv1vPB80nq2BZCzhFVR5O4VznYbsX0wZmow@mail.gmail.com Also, I looked through the original thread, and found this was discussed at the time: https://www.postgresql.org/message-id/b1b68453-9756-bd92-306e-a29fc5ad7cd7%402ndquadrant.com > >> ERROR: value "62812" is out of range for type smallint > >> STATEMENT: SELECT abalance FROM pgbench_accounts WHERE aid = $1; > >> > >> (In this case the error message contains the parameter value, so it's > >> not a very practical case, but it should work, it seems.) > > I guess this error occurred /while/ binding, so the parameters probably > > weren't yet all bound by the time of error reporting. > > That's why the error message came without parameters. > > I see. But I think that could be fixed. Change exec_bind_message() to > loop over the parameters twice: once to save them away, once to actually > process them. I think the case of a faulty input value is probably very > common, so it would be confusing if that didn't work. https://www.postgresql.org/message-id/resend/20191205231550.GA28677%40alvherre.pgsql > One problem I noticed is that we don't log parameters when > exec_bind_message fetches the parameter values. So the very first > example problem in testlibpq5 fails to print the values of any > parameters previously seen. I don't think this is a real problem in > practice. You still get the unparseable value in the error message from > the input function, so not having the errdetail() does not seem very > important. I see that as a deficiency (as Peter did), so I'm requesting to improve that now. It's not a bugfix, though. -- Justin