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 1v6SM6-004v2T-5B for pgsql-docs@arkaria.postgresql.org; Wed, 08 Oct 2025 11:29:14 +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 1v6SM3-009Vt2-Oc for pgsql-docs@arkaria.postgresql.org; Wed, 08 Oct 2025 11:29:12 +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 1v6SM3-009Vsu-Ge for pgsql-docs@lists.postgresql.org; Wed, 08 Oct 2025 11:29:12 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6SM1-0011hv-2x for pgsql-docs@lists.postgresql.org; Wed, 08 Oct 2025 11:29:12 +0000 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-43f645f162aso411901b6e.1 for ; Wed, 08 Oct 2025 04:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759922947; x=1760527747; darn=lists.postgresql.org; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=6/brP8TpZVXAnMGecLNeH470GVTFYiV1W6+CEXdwilg=; b=AKUlSj4r4bsSsFhV/z08VyuUTPEEiaEwEPc/0XILcH0Odm7NS7pw6xJe0kVRG9eBQR iv0J0E04a+TdR7P9l3sBEK61bwuAibRszHyY+ABEHPh9KsV1v17xl5tYIqcnW9hOIrC2 Nz6pjCH+tbW13P1ULKJ894aLzc/HbSEmU1T3JJfhagxFZxESbb3rNEoKG0lCU/C3QRqN fnkFJPFBuvSbWo+KiMn+t5vSuMnsotlbPjMXPcfU/BPEato1SP79XZscl91mKrMQpjrN 1pQVS+/dSdsCZSvKxNXb/BKjkTRgWNI9m+VklQEjGFkLeCdsazQ7oNijTXvcJAReVeSy Q0RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759922947; x=1760527747; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6/brP8TpZVXAnMGecLNeH470GVTFYiV1W6+CEXdwilg=; b=hBmszdVhXYKsxebG/6MdfwZi1eEXc8SOBCtPbEn7jGEKxP5pSE+Y6m2Ie33efYUvz8 AX/s1yUwSzFaXSKbeqwy2+jngIW8aDTPyiw5Rj5RHpJBD52r/Pgg0c4mHGeo6kc+6HJY X/bGJ6A+w6DAwDXXSGy/UoIPBGLUoC1Wa00n4elQKyRawqVg0ayrz++tkj1sVD3Bo6Jr WVeMt1QLd6Ix1f4YcvxSJIM0Oj2xXYItcQHAzHTpFGZzkBq28ZLNwDrkogdz1iiGg3dF C8vBfWqM7ZFl4AhrIfxO/oePU4MzeO8PDLfXkIWfpuPVzy2Ik9hgLK5bP5Mzi4c7sXZa fuJQ== X-Forwarded-Encrypted: i=1; AJvYcCXC5RhQeTs1kI+Nk0RUCsi17PHDp06kqhysyQ/t0hwdbwhZrTHeFytsROgHEw+Brbs1TtSssVVxtPrI@lists.postgresql.org X-Gm-Message-State: AOJu0YzylhPT16r1cMBUYd7v8F8t1jHMVE7+6MlFRC14HZiZs5UAJWOd /2s385BoJ5KpWIBfGyropxj95cDFGq60oFPyO966aZIjVQxM5rYdtwpWYPbidUz379nMg++6nAi cWkJI+bLt4t8IAm01vx9/CvkcNw4K90y0Mw== X-Gm-Gg: ASbGncvb0Efatw6k1TGz5eo8l98/eC3l+Vt/U6iLLjbh2Jp41CEWMfIxCiStbgs30p2 iBGJ0QkqP7kAPIK/FR3P4ny3DcVC8meHjjXrWNCwXT805OjvmdpckTUaJRyaCMMmYgwCU41HRVo mGkrKD9U9i1DN3y3XXIrYDwfzcwNZ0YQed0tsacbDTa4CgTgS+60fNzibkZBPcDMdnrfmCl9ULn qALyR3tjGzZuH5yWqwXKla1G719Hqc= X-Google-Smtp-Source: AGHT+IEveXyPlDWpqI5uh+ZH6DArVaDtBb5qEJvfY7E4K2sHzFLOSoIDIP/o5fh3QA+4ZdaC4UOZWEdn5FgySKhxmUE= X-Received: by 2002:a05:6808:bca:b0:43d:20fc:2c43 with SMTP id 5614622812f47-4417b8db4d4mr1586905b6e.14.1759922947349; Wed, 08 Oct 2025 04:29:07 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:1cf:0:b0:5f3:5bf6:6b0b with HTTP; Wed, 8 Oct 2025 04:29:06 -0700 (PDT) In-Reply-To: <175987603436.768.10549246436481476867@wrigleys.postgresql.org> References: <175987603436.768.10549246436481476867@wrigleys.postgresql.org> From: "David G. Johnston" Date: Wed, 8 Oct 2025 07:29:06 -0400 X-Gm-Features: AS18NWCxhe1jgwd8U1Eqj82pJ34Vp_0EgTpJt8jSUgbsAh5Pg8uMS6Alr24ITOw Message-ID: Subject: Re: UNION does not append To: "trescher40@gmx.de" , "pgsql-docs@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000001be29b0640a3fe1a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001be29b0640a3fe1a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, October 7, 2025, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/18/queries-union.html > Description: > > I'm very confused about this statement in the documentation of UNION: > "UNION > effectively appends the result of query2 to the result of query1". > Because, if I append one item to a list, it is still the same list. But i= n > the case of UNION, it's ""copied"" into a new anonymous derived-table. > Alias > don't work anymore, which I would expect if I just append some rows. Or i= s > it like "effectively" means that this statement is not to be taken > literally? In that case I would really appreciate a more detailed > description, that after the UNION with tables a new anonymous derived-tab= le > is returned and the original first table can't be accessed anymore. Thank > you for taking your time to read this even if you disagree. > Yes, if you place a set-operation using query into a subquery context the subquery has to be given its own name: and the individual from clause relations of the contained query are not exposed. This is just how subqueries work. If you don=E2=80=99t place it in a subquery the rows are just sent to the c= lient. In both cases the word append simply means =E2=80=9Cusing the column struct= ure of the first component query=E2=80=9D. Though Imsuppose that is strictly =E2= =80=9Ccolumn names=E2=80=9D since types can be changed to a more encompassing one if nee= ded. David J. --0000000000001be29b0640a3fe1a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, October 7, 2025, PG Doc comments form <noreply@postgresql.org> wrote:
The following documentation comment has been logged on th= e website:

Page: https://www.postgresql.org/docs/18/queries-union.html
Description:

I'm very confused about this statement in the documentation of UNION: &= quot;UNION
effectively appends the result of query2 to the result of query1".
Because, if I append one item to a list, it is still the same list. But in<= br> the case of UNION, it's ""copied"" into a new anony= mous derived-table. Alias
don't work anymore, which I would expect if I just append some rows. Or= is
it like "effectively" means that this statement is not to be take= n
literally? In that case I would really appreciate a more detailed
description, that after the UNION with tables a new anonymous derived-table=
is returned and the original first table can't be accessed anymore. Tha= nk
you for taking your time to read this even if you disagree.