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 1saypU-00ClQY-CT for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 14:36:56 +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 1saypR-00EEHw-8Z for pgsql-general@arkaria.postgresql.org; Mon, 05 Aug 2024 14:36:53 +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 1saypQ-00EEHo-Te for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 14:36:52 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1saypK-003ESz-2u for pgsql-general@lists.postgresql.org; Mon, 05 Aug 2024 14:36:51 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5c667b28c82so2857887eaf.1 for ; Mon, 05 Aug 2024 07:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722868605; x=1723473405; 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=+gv3oDBrQWoc2F5kwVD9hCNBfMRjfREVU4h0u8ckjMc=; b=lnsbPscNjtbs39/B24GFewUIFBt/A853Z7dCPRmysvwXkBZo0vKKGeSTZ6DBTTvxrU QHjTosdao+zTJz4MfyMJ//YyyJKM/qiYOWp6vH5pl/Nygo47BxUEWklqsCdO1bGIPLiR 1CUKo0DpLuf5up128j832pp+kpx+iAwDPzFeOaHTRpAs1wFX/QMqDNAKGYlHJcwVFKGg mc1MfLtoIbPHkyqUGTU15ygsAd3GYx2AiaXLFiEi7T91sk9WnO5q373WAOMSNw/r08JR Cks+8byLlb7AmbraOoTNZ7cjcyq8HgV5X9Nh4toxC780KS7ZGyfnvQ+ELo7u782ofIDH wiJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722868605; x=1723473405; 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=+gv3oDBrQWoc2F5kwVD9hCNBfMRjfREVU4h0u8ckjMc=; b=Z0vqBy5p9ZBy/Pb2B9FDps9j9X4Q+LxGike9zM8BOHCvkaK2VGkWeRpVLUFwUu9Hur SURgX5lpEB07U5Z/wBI8kaTy1ybKsecjgcbIq95xXzHloc6nGBCXIjEHkPXLy7Z4N94T pf94g5b46wV7q/oSfO6euXVqtr8O+MqN4J76unuVl2ictQQGf9uV6g2hE5tcFoB5waud m/g6wedrJoHYVJSkbcqjDFKs8KTg0M6dS5VC8j9P5xnq4aE+UZrtkVgdE7OO6ATKuAbo 80DjGYtTPpGrtIN0ifciSTAEq1uFUUSkkwO2OkhlWOCxMP2nM22Oc+K0SJdLgLAateGs nKMg== X-Gm-Message-State: AOJu0YxwF6GSLWfCBha4DzggmDrGg/XZvQCFN+Nbo9dUVIdTUwSx2uFn 2Lp4JyJJ9kkbrOJEibsyYdsJpL4/goaYp49V78dDiPeirxy7dduft7H/2wLj+6fjk0a6/pI7anM YQwR0xY4ts13C0JSiLq9xbtUD96p+g19K X-Google-Smtp-Source: AGHT+IFB3kWGnyFx2FbEMzZLtcPq3IJYYztTZLCsvmZyWtoi24lV8tE4hQ0w58Jhmk8xY96DySZufE/EwhHYjtYVZZg= X-Received: by 2002:a05:6870:b629:b0:260:23bb:1082 with SMTP id 586e51a60fabf-268925fed04mr4847416fac.10.1722868605206; Mon, 05 Aug 2024 07:36:45 -0700 (PDT) MIME-Version: 1.0 References: <1064261.1722866217@sss.pgh.pa.us> In-Reply-To: <1064261.1722866217@sss.pgh.pa.us> From: Dominique Devienne Date: Mon, 5 Aug 2024 16:36:33 +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 3:56=E2=80=AFPM Tom Lane wrote: > Dominique Devienne writes: > > In https://sqlite.org/forum/forumpost/df23d80682 > > Richard Hipp (Mr SQLite) shows an example of something > > that used to be supported by SQLite, but then wasn't, to be > > compatible with PostgreSQL. > This seems correct to me. The scope of the ON clause is just > the relations within the INNER JOIN, which does not include t1. The [SQLite doc][1] does mention: 1) "With UPDATE-FROM you can join the target table against other tables" 2) "The target table is not included in the FROM clause, unless the intent is to do a self-join" which one can easily read as the update-target-table being implicitly part of the join, and thus OK to JOIN-ON against. Yes it is the SQLite doc, and not PostgreSQ= L's, but naively I tend to agree with the OP (on the SQLite Forum) that it "ought" to work. In both SQLite (as it used to), and in PostgreSQL. I'd rather SQLite and PostgreSQL continue to agree on this, but not in a restrictive way. Which would imply PostgreSQL accepting it (a tall order...). Or perhaps SQLite should allow it back. And PostgreSQL catch up eventually? 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. Thanks, --DD [1]: https://www.sqlite.org/lang_update.html#update_from