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 1sazLB-00CqtM-Gk for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 15: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 1sazL9-00EUsg-7D for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 15:09:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sazL8-00EUoe-Ra for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 15:09:38 +0000 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sazL2-003EiE-9v for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 15:09:37 +0000 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-709345dd01dso2450446a34.0 for ; Mon, 05 Aug 2024 08:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722870571; x=1723475371; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gBYFg0t8km9G0lU23KFuVJjTI4hihjFgB3OsDfXg4aQ=; b=EIkj7fhOK9j/lS1c/iNW243i8VeGC4bFg/LOejhZ+DFL1fhM8XDfCvAgaSjQOYUlD6 ZrjsOqzenNjyveFaq1HoFzeP8I1Nzu7XUl8AANXch88HsITQKpLUg/vzTwkUithUqwrA ohXG3f0aO3m6c687MldBkRCNcTdQjpEc33Y05xUhzCHcPtfgHJ7bOuXVJALCRl+Fh49b nKjk7gzTIfoCbpSOWz0mlcydwcFPRQSneBixbWM3jhPUsfiNPusnLHbDmMwA5NTjl25Q zXbJJ1lBl43CSfnAxdE7bxqHcp67rljdRn5JME1JMUxInoqBMBS2QBliixPkAECKYEpy q5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722870571; x=1723475371; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gBYFg0t8km9G0lU23KFuVJjTI4hihjFgB3OsDfXg4aQ=; b=OxfmPWuxM7AFTePAUzmmimIIUHrNnS7pJF99eE2cFAUNZlB/nO+E0wz8ubzvJO62eD XDowcI3qR3zdWuAef0eqxp1iiawEodr3VJ+oAH+FNMMARCI0GgPYzbj0b5aSeGqnhPVk MUtktXcD5cViDYeis/uDLFGUtVVqpAs4VWvc1O6dIF16GCG/qxfHO9ItjsV0ru8tZyW6 MZPfQ/cYhaH1QgiTRKnCr2bCIdG2FLe8nj+d287vIhDvPaDrQ5cjnsX8sK49uNuAOjyM hAXZ6VL9tEnuaNsYB7A+kH1m0EkZw13E573dO4E/mZVXieQelES9pMSZ6uLoxhlawscY 15rw== X-Gm-Message-State: AOJu0YyOi6bUfuq83vd6Q1trG8krFpvDGr91SQRKYd0yJRypW3tAvUN7 RNc/l1JPPl/aQWQtOXv2ojabERjw2CmQT+iDwqJJY/1drti7A5/Xzcx9Ww5+KxiTait+VkOlwag ep+szGzFJTJR89y/wMZ7kMfY/7rU= X-Google-Smtp-Source: AGHT+IE4WgsYc0hZhxFvmUS5b8p03KqewDRhHduUZIA+lxxOkSZxSBNpRFeK+IEoR46YsZL4maIFJyjQmIHJ50Loiks= X-Received: by 2002:a05:6870:b91b:b0:265:b32b:c465 with SMTP id 586e51a60fabf-268877a4c75mr5912428fac.9.1722870571546; Mon, 05 Aug 2024 08:09:31 -0700 (PDT) MIME-Version: 1.0 References: <1064261.1722866217@sss.pgh.pa.us> <1073701.1722870110@sss.pgh.pa.us> In-Reply-To: <1073701.1722870110@sss.pgh.pa.us> From: Dominique Devienne Date: Mon, 5 Aug 2024 17:09:20 +0200 Message-ID: Subject: Re: UPDATE-FROM and INNER-JOIN To: Tom Lane Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Aug 5, 2024 at 5:01=E2=80=AFPM Tom Lane wrote: > > Dominique Devienne writes: > > The reason I find the restriction damaging is that `FROM t1, t2 WHERE > > t1.c1 =3D t2.c2` > > is the "old" way to write joins, versus the "newer" `FROM t1 JOIN t2 > > ON t1.c1 =3D t2.c2` > > which IMHO better separates "filtering" from "joining" columns. FWIW. > > But the whole point of that syntax is to be explicit about which > tables the ON clause(s) can draw from. If we had a more complex > FROM clause, with say three or four JOINs involved, which part of > that would you argue the UPDATE target table should be implicitly > inserted into? Wherever an update-target-column was referenced in an ON clause. Like SQLite used to support. I.e. possibly multiple times even, I guess. Yes that does imply the update-target table in not explicitly named in the FROM clause, specifically in the UPDATE-FROM case. Personally I don't find that "offensive", it's explicitly part of an UPDATE= . > The only thing that would be non-ambiguous would > be to require the target table to be explicitly named in FROM > (and not treat that as a self-join, but as the sole scan of the > target table). Some other RDBMSes do it like that, but it seems > like too much of a compatibility break for us. The (old for now) SQLite way would be lifting a restriction, so that wouldn't be a backward incompatible change IMHO > Sadly, the SQL spec doesn't provide for a FROM clause in UPDATE, > so they offer no guidance. And that's precisely why SQLite and PostgreSQL agreeing on a precedent would be nice. > But I doubt we are going to change > this unless the standard defines it and does so in a way that > doesn't match what we're doing. OK. Fair enough. I'm just expressing a personal opinion above. Which the SQLite Forum OP also supports I'd guess. FWIW. Thanks for your input Tom. --DD