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.96) (envelope-from ) id 1w5yTY-003ouX-2r for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 04:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5yTW-007TTf-0O for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 04:07:10 +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.96) (envelope-from ) id 1w5yTV-007TTX-2a for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 04:07:10 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5yTT-00000001PWn-0go1 for pgsql-hackers@postgresql.org; Fri, 27 Mar 2026 04:07:09 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5a0faa0d15cso1656123e87.0 for ; Thu, 26 Mar 2026 21:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774584426; cv=none; d=google.com; s=arc-20240605; b=kKRgf/vli/PpVgU+EPBO9LrPSPitM935n1mW8YGFvVwMBAriDqe5WH8awBoRhScNPQ bXUvMVXjKqW/L+1GDcVaf94Mw6I09CAWI9VRIPt5c6hWh6VyDHhWmyjjClKAiXR+6+ye WZQZCdi+SrReE3KB2F1aQI107fbnaWCNzk0zh3MGUzij9orZe87q2eIwiRSr0XlnHVJA g5aG+nr856JyFbkc74QCVKwEM5HjvUAQNMMFKsL99k8WjdrU6B8Q/7tHCE3xi+42i3WP oUUa8oO7x/1Q3L2UiLGQ3bKwZkSwl11Vo4lVZUwbfZti7ZGaTfHZ+EwlmIkzOCNeaD8y nPbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3qXZzDSxl3e0hYOw0ROoCmO54dq2DNunBlMTgFurPDo=; fh=FrYk27HPOFj/e7H0SH7ta5tzOURzEMX93wYDw2AB+YE=; b=j2ZGq+uUJP3lWwcBnk/66wr2qa3cb+/+S89dyBqFWb0VllzHJesDm5mUJc+L7d/Lja y0H48baveMW6g7q0jrAsJr8JG90jG5IfLd28bLbvt3iMO2as89xbWwLcbedbFM0Eg4v3 Vnm1wQcuPgX3LAZ86Jx5aHtUwD2ZuoCNEcXmqm7R7AuZGOkMbO5XSMQXc8UnztNxnVfg O8eNSD0PO+tWBvTfPwlrY/vjMyuS5FbVDkwG4R6Nyv2VuqkKrI5z2dAvpm0mBI+sbqig iMfpmQGb2l4604mMAcsmZ05nBVt14XKFakbuRulzkxvB2SqXVBtn0JeQ8h589PwvLk6O CkqA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774584426; x=1775189226; darn=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=3qXZzDSxl3e0hYOw0ROoCmO54dq2DNunBlMTgFurPDo=; b=qhU/Dv0Bbi1s75VBzQZBRcN7ohWqBIpQXMJnb6adaR4fpvtxMcpsnz2OvSz9bFEikF GAm2DtuJqxuPjE2gI8A/yuVTurkBC6IYm+t+rkrd2OD2ScnU0jYxmAD1MfOLheRrjnOz tIKPzkzK3XjIq95tRePjTNt6TxsfwUBQ9XFeg9OWg8nqasH6aqqT7xug8/cNNem8Gd0A MFkrfHHOB+gt/bkErIGd5hrQn0cRxKE10GUxH3cjT4Dg176C6t9mGSWbgG3xjuOdFtlr v14yiENPahwu6MXaaGK6PEVOOst9rbR4j7sUc1GK29RX1rUT2DRcwtwupEvLEoh24PpI lESw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774584426; x=1775189226; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3qXZzDSxl3e0hYOw0ROoCmO54dq2DNunBlMTgFurPDo=; b=f+vHdljJgjq42QtanujpBOQmtBR9eIlf1/nAN44t1Ewt8MJ/BynB4sLh5DniEE+IWp PqqL8/LBfUQG9aCqJu02BPYa7JZG8j+9Fpm6eVtu/rDpC+xMDJ17ZBxII8Da0qMW5+Uy czJpGNSmsYOZ6P2/M0mbQA6eC+C5ErqKqR18o2R+J4PXcn0kKFCcDK6qVa1V1qPjSjNG lf/Em4nSx1/CBaN4ZK7ozutpbrJxKfyMJ5MI4Y0etTsiP7zjnZ83ZoIEpp147QHG5DTA 769uEtJGRZEMRLVWbctZHxTWyWcLZoLOjW3lh+aGIf4yIdsoW43Zcu/Yv2olLeW9Aii4 VpMA== X-Forwarded-Encrypted: i=1; AJvYcCU4jkW4EssMzi9cmMSNgxlXRcidXypWS2LzxVht+x6oHHjmQLyBn/4eP2ve9aTaNqT1z2vL7rYigzRPZFfs@postgresql.org X-Gm-Message-State: AOJu0YywNP6nCGaZV2BYAeoneKVofarwKsfdERHffH9dr4hwVCOeBmSz dPl79qUNevncW8/UmHiY7lOueQsZ4YPlDf06daUPhyjndy+wnkgNHja+dHvTB3AAXnlObJVKloX oLikgZvUxpKomBy91ma2ZXSopxbMQ/eYW04gU X-Gm-Gg: ATEYQzzvlYThPIE3v4dBx6jSc62RwOuUrZGX5EovQV1RDtusqdE76tEfOli31CMmZnc dz2RyqKaeZ6rTQHeOTuoFnLsG3qAjLC3bkEOZcgT5A8LKva3HDETav5tZSUjYSfLMeN/BpmS7Qe c7fqo3CcVfB7oLWBMYwV/BePYdcuZbnIHBTkCd5AgYcMzswmRJaw6etUnbwkpGj7gvEOMgIhJXi 0NiDo/vtANc7SI4HoWeez/Luug16o/DduRdnn+OYS2P9+fkHt2qqfX8Vd2LoqJUvNwQ/hvlXlNH LjuXY6ejvA== X-Received: by 2002:a05:6512:1096:b0:5a2:a753:929c with SMTP id 2adb3069b0e04-5a2ab7e8d33mr309737e87.8.1774584426217; Thu, 26 Mar 2026 21:07:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ajin Cherian Date: Fri, 27 Mar 2026 15:06:54 +1100 X-Gm-Features: AQROBzC1uYjabnz6YgZQYUZyY52_XFX58pjoC43-CfUPEZEkEIaqpCI48JcYOIY Message-ID: Subject: Re: pg_publication_tables: return NULL attnames when no column list is specified To: Roberto Mello Cc: Peter Smith , PostgreSQL Hackers 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 Thu, Mar 26, 2026 at 11:49=E2=80=AFAM Roberto Mello wrote: > > On Wed, Mar 25, 2026 at 5:32=E2=80=AFPM Peter Smith wrote: >> >> FYI - the patch failed to apply for me because of publication.out issues= . >> >> There appear to be some missing trailing spaces in the result table head= ers > > > Apologies. > > Generated a v2 patch. Applied cleanly and tests passed. Hello, Tested the patch and the patch fixes the bug as described. My tests below: postgres=3D# CREATE TABLE my_table (id int PRIMARY KEY, name text, status t= ext); CREATE TABLE postgres=3D# ALTER TABLE my_table ADD COLUMN old_col text; ALTER TABLE postgres=3D# ALTER TABLE my_table DROP COLUMN old_col; ALTER TABLE postgres=3D# CREATE PUBLICATION pub_no_list FOR TABLE my_table; CREATE PUBLICATION pub_explicit_all FOR TABLE my_table (id, name, status); CREATE PUBLICATION CREATE PUBLICATION =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D On head - without patch: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D postgres=3D# SELECT pubname, attnames FROM pg_publication_tables WHERE tablename =3D 'my_table' ORDER BY pubname; pubname | attnames ------------------+------------------ pub_explicit_all | {id,name,status} pub_no_list | {id,name,status} (2 rows) postgres=3D# SELECT p.pubname, pr.prattrs FROM pg_publication p LEFT JOIN pg_publication_rel pr ON pr.prpubid =3D p.oid JOIN pg_class c ON c.oid =3D pr.prrelid WHERE c.relname =3D 'my_table' ORDER BY p.pubname; pubname | prattrs ------------------+--------- pub_explicit_all | 1 2 3 pub_no_list | (2 rows) postgres=3D# SELECT p.pubname, pr.prattrs AS raw_catalog_attrs, gpt.attnames AS view_attnames, c.relnatts, array_length(gpt.attnames, 1) AS synth_len, -- Replicating the buggy CASE WHEN heuristic from tablesync.c CASE WHEN array_length(gpt.attnames, 1) =3D c.relnatts THEN NULL ELSE gpt.attnames END AS heuristic_result FROM pg_publication_tables gpt JOIN pg_class c ON c.relname =3D gpt.tablename JOIN pg_publication p ON p.pubname =3D gpt.pubname LEFT JOIN pg_publication_rel pr ON pr.prrelid =3D c.oid AND pr.prpubid =3D p.oid WHERE gpt.tablename =3D 'my_table' ORDER BY p.pubname; pubname | raw_catalog_attrs | view_attnames | relnatts | synth_len | heuristic_result ------------------+-------------------+------------------+----------+------= -----+------------------ pub_explicit_all | 1 2 3 | {id,name,status} | 4 | 3 | {id,name,status} pub_no_list | | {id,name,status} | 4 | 3 | {id,name,status} (2 rows) --------------------------------------------------------------------- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D After patch: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D postgres=3D# SELECT pubname, attnames FROM pg_publication_tables WHERE tablename =3D 'my_table' ORDER BY pubname; pubname | attnames ------------------+------------------ pub_explicit_all | {id,name,status} pub_no_list | (2 rows) postgres=3D# SELECT p.pubname, pr.prattrs FROM pg_publication p LEFT JOIN pg_publication_rel pr ON pr.prpubid =3D p.oid JOIN pg_class c ON c.oid =3D pr.prrelid WHERE c.relname =3D 'my_table' ORDER BY p.pubname; pubname | prattrs ------------------+--------- pub_explicit_all | 1 2 3 pub_no_list | (2 rows) postgres=3D# SELECT p.pubname, pr.prattrs AS raw_catalog_attrs, gpt.attnames AS view_attnames, c.relnatts, array_length(gpt.attnames, 1) AS synth_len, -- Replicating the buggy CASE WHEN heuristic from tablesync.c CASE WHEN array_length(gpt.attnames, 1) =3D c.relnatts THEN NULL ELSE gpt.attnames END AS heuristic_result FROM pg_publication_tables gpt JOIN pg_class c ON c.relname =3D gpt.tablename JOIN pg_publication p ON p.pubname =3D gpt.pubname LEFT JOIN pg_publication_rel pr ON pr.prrelid =3D c.oid AND pr.prpubid =3D p.oid WHERE gpt.tablename =3D 'my_table' ORDER BY p.pubname; pubname | raw_catalog_attrs | view_attnames | relnatts | synth_len | heuristic_result ------------------+-------------------+------------------+----------+------= -----+------------------ pub_explicit_all | 1 2 3 | {id,name,status} | 4 | 3 | {id,name,status} pub_no_list | | | 4 | | (2 rows) One observation from reviewing the patch: the test suite covers the partial column list and dropped column cases well, but is missing a test for the two-publication conflict scenario (one pub with no list + one pub with an explicit list of all columns on the same table). That is the breaking change called out in the original report and probably deserves its own regression test with a comment explaining the expected behavior change for users in that configuration. Patch LGTM otherwise. regards, Ajin Cherian Fujitsu Australia