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.98.2) (envelope-from ) id 1xDjQn-00000000fuR-0uI9 for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 14:12:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xDjQm-0000000Awpe-0ryP for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 14:12:40 +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.98.2) (envelope-from ) id 1xDjQl-0000000AwpW-3lHw for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 14:12:39 +0000 Received: from mail-ed2-x0d.google.com ([2a00:1450:4864:33::d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xDjQk-00000000UIZ-1FmF for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 14:12:39 +0000 Received: by mail-ed2-x0d.google.com with SMTP id 4fb4d7f45d1cf-6ac6fa788e6so2201010a12.1 for ; Mon, 05 Oct 2026 07:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1791209557; x=1791814357; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=i7yDIdkG4dpezGknHc9S5ohjpkbasH5FSU+F/EfkVak=; b=eQI5DJrT6KgSK4DI42Lu/WymeI5gpYGdGwQN6UNg+w5b8so1x9P66JpoIHfrJGxMxz TO6/CxmNZto15SN59XJ5mvX0jAvQxoHVFhWSnw7HDjTGtXkKJfpFzRsy0AIBffXyM8g3 QRZZ/c7oROpdcNh4YoeYccaA3YrDaOjGj78bU329cuYO0lOesX7SGJqx6O8PmCtOi6QR g2QWzFCJVqsGuhh/d3yoPcvvXmnkt3YMZP16L2a1zrYBwN5RO8FZ8CJBqAT3gwJy6v8r 5eNGPOtB5y57CoH6xbct1QQmhl78y5QfNoXhTMCvmVZCjFx/0i/h2wepboBcfzUj7DDG shHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791209557; x=1791814357; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=i7yDIdkG4dpezGknHc9S5ohjpkbasH5FSU+F/EfkVak=; b=jFaOoAJ582L7RNtQB39CjsYeZwypCu10TtfhdDkiDFmPBY2m5k2pRoMZyAQCNuteLs 3kYZXNUSELGF8Tv8iy/II4O0U3oJ07WMHR147FCWSEWH+CTHQJ8WXU+dGkPNGoU2678z 0m6nMJ8b+0fHzuSmNCgXr+u8Kvugpo89qkyseuN3FS5ZCixiwt+83Cyc58TkQyJI0X3W WM0bcOHDkByB+N+DKS1tmd3oG0aFg9cbSQCcZzpL5q3dV4bBmX4ITq9PjMu96Bz1TlWj rh1Qzqfjgrn74eYdRPhdT1+9QTczRxmTm7s4x+joGxp+VA4eXwspYOtHPja9BTFcz7b0 zyzg== X-Forwarded-Encrypted: i=1; AKwUvBy6nEu1cIVlUnyg0XUNNffzwT9lp34k+aCDm1lEj6l/NxX2bjqqZgW5T6TSyX4/HPC6pjja8wQ8vD2KMIK6@lists.postgresql.org X-Gm-Message-State: AFq9FYIMBuaQK9jKD6bIZScQDG2/lt416AhTz/a1i8wYoZDbmy+qX3j0 SFAaDMqQnHHc1euXz6l5hrW6iaGj3thmGXSArvF/2AHnFJ11kZAtgoBY7bIjUzc1Y44= X-Gm-Gg: AYBFou2sTMlw+vY0th+Pl0Frcybvc1khyiL9xc8LwoFA8aXKio8pvIIR3JiZx0rgPQn laYA4BEqTw3t0F5yT7NUPTdIkgHFbPH73fGDCHIZtKHuylGnLq4oJVIMDZ7DI5QJuUtn0HLt7Dl NrdVL2+b9aq1n0jkz5g1CxhdPxdvaJKXmwQ03Wkh8FaGTe5Qfx+ak8wzkS7iclJwcw5G2AF4jtK GxXoVuOBH+9TLdWjmg7dxXycDOPE/+Mj6DwfgkLHzFLURdomLt4GOgbyTH5SZvIvlxY7cSVvLkp PA1AGC9O6+DYFLh5vauf4Q8E0wMNwAoH+CUJVEwK0sBwS+VywbFuVH4nUW+KLR1+kY5ZzZTw/xG 4ARdq+7DDdIjYFQ+DmFEFZ3SkJBnNHZGNqQBKeFgpfuDyA07K/nkTtJeo+tSgx7Yl2nu0FZPhc6 OsdPRUY5/h9dSGIFN3/RpRapB+yvxajM59xxFhM0dL6fteOXBEiHtVFcZXPEYZ5a6fdlczu4P6+ 9+6Zk7ONPfEUuHCZF3tnHJfG9c= X-Received: by 2002:a17:907:2da6:b0:c25:541:fd3a with SMTP id a640c23a62f3a-c2e4a8fd341mr905028866b.7.1791209556770; Mon, 05 Oct 2026 07:12:36 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:8b5b:c776:83dc:e5e8:cfc]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c3156301769sm85910366b.50.2026.10.05.07.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 07:12:36 -0700 (PDT) Message-ID: <1ceec3736795f744417d6467796bad12e836ad1c.camel@cybertec.at> Subject: Re: bug or feature From: Laurenz Albe To: "Carl.Weierstrass" , pgsql-general@lists.postgresql.org Date: Mon, 05 Oct 2026 16:12:35 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-10-05 at 10:26 +0200, Carl.Weierstrass wrote: > I want to delete some data from table test1 und protocol the deleted=20 > data in table test2: >=20 > The solution with two statements >=20 > begin; > insert into test2 > select * from test1 > where 1 =3D 1; >=20 > delete from test1 > where 1 =3D 1 > returning *;=C2=A0 =C2=A0-- show deleted lines > commit; >=20 > works fine, but the more elegant version in one single statement results= =20 > in a syntax error >=20 > begin; > insert into test2 > delete from test1 > where 1 =3D 1 > returning *;=C2=A0 --return deleted lines > commit; >=20 > psql:test.sql:32: FEHLER:=C2=A0 Syntaxfehler bei =C2=BBdelete=C2=AB > ZEILE 2: delete from test1 >=20 > Is this a bug or a feature? That's incorrect syntax. Try WITH cte AS ( DELETE FROM test1 RETURNING * ) INSERT INTO test2 SELECT * FROM cte; Yours, Laurenz Albe