Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tCLMj-00Gp93-L9 for pgsql-general@arkaria.postgresql.org; Sat, 16 Nov 2024 16:09:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tCLMg-00EwDD-5S for pgsql-general@arkaria.postgresql.org; Sat, 16 Nov 2024 16:09:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tCLMf-00EwD5-6a for pgsql-general@lists.postgresql.org; Sat, 16 Nov 2024 16:09:38 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tCLMb-002HQw-HP for pgsql-general@lists.postgresql.org; Sat, 16 Nov 2024 16:09:37 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 9C493254009F; Sat, 16 Nov 2024 11:09:32 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Sat, 16 Nov 2024 11:09:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1731773372; x=1731859772; bh=bnfC1cerB7YD0h3BOTGJ4/Pfzl7MgEz9uXQ+OjpGCwY=; b= Uehn6Rm4VHLVZMA9DM2afNJMWyWmXbKMJ1mgZNFYGFUWJ02TT5l6bz5g5y1WSgpW LrHPhlBr15pMhdiy0AwP76Jh06UWmowk+MmT8SsjoSkrGw0tAwmkipZSXYN/l/MH vM/SEB6ecghI3TfZ1UGvj/ooh72MdZMUN2Jlv/ksOuD/rj29JGdlpd5kdzVUE5Bx w/tw292q+awXQFP/+MqC6Nk4tQ3h05dMeawPV5U7CUFjL4R9CLdwKtM1nTsKoVHH V2u4gmCYnPMlY7ap3uLIlD04HCQLJgD0Nx05uTp/mK8jgIX/mRumFsSS3GRJomLA 5p+zoO1MZmM6Jflkrfe19w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1731773372; x=1731859772; bh=b nfC1cerB7YD0h3BOTGJ4/Pfzl7MgEz9uXQ+OjpGCwY=; b=B1QgO/YhrmKKrrA/h q0tI2vTli2v1Fn6wjksJsJYBh2x2G/su3NDI5Rk3S5T/7NhqznoWE0vu9ae/TzL5 Tkdd974FchiysadDaYdeTw6gvybaY4/P210hb6pgZAmAUDQW/RBYuQWqZabWj1VN dT/nvFhBrZp+UckIgmnvyqC/wuXy/AltAJeANpx/ajXqnUMRimSiW5mMhH9cx8qI 4fgWcURT3pbiUQQ86PqdTE2C8WY1eOf83rMKiu4j4KAtwVDKtVp+qRsc7sVId6L2 /r9wM92BsEG96ez/v6kzwWPZix6JMPFX5jzxXuQy+dDuy3a2t0cIprxyfsxmIcMz 4fJEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvdeigdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecu hfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrg hklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfek uedtffejveegffegjeevtdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgr vhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtoheprgdrmhgrnhhtiihiohhssegtlhhouhgurdhgrghtvgifrgihnhgvthdrtgho mhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrh gvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 16 Nov 2024 11:09:30 -0500 (EST) Message-ID: <574887e1-21a3-4847-9933-c05ac56edde2@aklaver.com> Date: Sat, 16 Nov 2024 08:09:29 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Getting error 42P02, despite query parameter being sent To: Achilleas Mantzios , pgsql-general@lists.postgresql.org References: <40d8beef-ff67-4c6c-828c-2941ca30fdef@cloud.gatewaynet.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <40d8beef-ff67-4c6c-828c-2941ca30fdef@cloud.gatewaynet.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/16/24 03:15, Achilleas Mantzios wrote: > > Στις 16/11/24 12:55, ο/η Max Ulidtko έγραψε: >> Greetings, group! >> >> I'm trying to understand a low-level issue. Am evaluating a new client >> library for Postgres; it's not particularly popular / mainstream, and >> as I've understood so far, sports an independent implementation of PG >> binary protocol. >> >> The issue I'm hitting with it is exemplified by server logs like this: >> >> 2024-11-16 10:28:19.927 UTC [46] LOG: statement: SET client_encoding = >> 'UTF8';SET client_min_messages TO WARNING; >> 2024-11-16 10:28:19.928 UTC [46] LOG: execute : CREATE VIEW >> public.foobar (alg, hash) AS VALUES ('md5', $1); > > At least for SQL level prepared statements the statement has to be one of : > > |SELECT|, |INSERT|, |UPDATE|, |DELETE|, |MERGE|, or |VALUES| > > |so CREATE is not valid, and I guess the extended protocol prepared > statements aint no different in this regard. It would seem so. Using psycopg: import psycopg from psycopg import sql con = psycopg.connect("postgresql://postgres:postgres@127.0.0.1:5432/test") cur = con.cursor() cur.execute("CREATE VIEW public.foobar (alg, hash) AS VALUES ('md5', %s)", ['test']) IndeterminateDatatype: could not determine data type of parameter $1 cur.execute(sql.SQL("CREATE VIEW public.foobar (alg, hash) AS VALUES ('md5', {})").format(sql.Literal('test'))) con.commit() cur.execute("select * from foobar") cur.fetchone() ('md5', 'test') > | > >> 2024-11-16 10:28:19.928 UTC [46] DETAIL: parameters: $1 = >> 'test-param-value' >> 2024-11-16 10:28:19.928 UTC [46] ERROR: there is no parameter $1 at >> character 57 >> >> Of course, I /am/ passing a value for parameter $1; and I can trace >> that the client lib sends it out on the wire as expected. (Attaching >> packet captures.) >> >> Heck, even the PG server itself says, DETAIL: parameters: $1 = >> 'test-param-value' — so it sees the parameter! But then, immediately >> unsees it. >> >> Am I being hit by a PG bug? Is this a known issue? >> >> I'd retested with master version of that client library, and against 6 >> latest major versions of PostgreSQL server (12 throughout to 17). No >> difference across versions spotted; the result is consistently error >> 42P02. >> >> Is the client library doing something wrong? How can the server claim >> there's no parameter $1 immediately after logging its value it has >> received? >> >> I did minify a 100-line SSCCE that reproduces the issue and can be shared. >> >> Any advice, or pointers on what to check next besides delving into PG >> source, I'd greatly appreciate. Thanks in advance. >> >> Max >> -- Adrian Klaver adrian.klaver@aklaver.com