Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL

Поиск
Список
Период
Сортировка
Искать

Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL

От:
Ante Krešić <ante@tigerdata.com>
Дата:
Вложения:
Hi all,

I've rebased and updated my patch based on Álvaro Herrera's wording suggestion.

I have left the function refactoring for future work as suggested.

Thanks,

On Mon, Jun 15, 2026 at 8:44 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
On 2026-May-14, Ante Krešić wrote:

> +                     if (!conForm->convalidated)
> +                             ereport(ERROR,
> +                                             errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> +                                             errmsg("index \"%s\" cannot be used as replica identity because column \"%s\" has an invalid not-null constraint",
> +                                                        RelationGetRelationName(indexRel),
> +                                                        NameStr(attr->attname)),
> +                             /*- translator: second %s is a constraint characteristic such as NOT VALID */
> +                                             errdetail("The constraint \"%s\" is marked %s.",
> +                                                               NameStr(conForm->conname), "NOT VALID"),
> +                                             errhint("You might need to validate it using %s.",
> +                                                             "ALTER TABLE ... VALIDATE CONSTRAINT"));

I'd rather make this error be

+           ereport(ERROR,
+                   errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+                   errmsg("cannot use index \"%s\" as replica identity",
+                          RelationGetRelationName(indexRel),
+                          NameStr(attr->attname)),
+                   /*- translator: third %s is a constraint characteristic such as NOT VALID */
+                   errdetail("The constraint \"%s\" on column \"%s\" is marked %s.",
+                             NameStr(conForm->conname), NameStr(attr->attname), "NOT VALID"),
+                   errhint("You might need to validate it using %s.",
+                           "ALTER TABLE ... VALIDATE CONSTRAINT"));

The other ones which you're mimicking are IMO in poor style.

--
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
Officer Krupke, what are we to do?
Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")

Re: [PATCH] REPLICA IDENTITY USING INDEX accepts column with invalid NOT NULL

От:
solai v <solai.cdac@gmail.com>
Дата:
Hi,

I tested the patch on my current branch.
Before applying the patch i was able to reproduce the reported issue.
I created a table containing a NULL value, added a NOT NULL NOT VALID
constraint on the column, and created a unique index. PostgreSQL
accepted ALTER TABLE REPLICA IDENTITY USING INDEX even though the
underlying NOT NULL constraint had not been validated and the column
still contained NULL values. The command succeeded and relreplident
was set to i, confirming the behavior described in the report.

After applying the patch i repeated the same test.
PostgreSQL correctly rejected the operation with
ERROR: cannot use index "t_idx" as replica identity
DETAIL: The constraint "id_nn" on column "id" is marked NOT VALID.
HINT: You might need to validate it using ALTER TABLE ... VALIDATE CONSTRAINT.

This matches the expected behavior, since a column with an unvalidated
NOT NULL constraint cannot guarantee that all rows are non-null and
therefore should not be eligible for use as a replica identity.
 I also ran the regression tests, and all tests passed successfully.

Regards,
Solai


pgsql: pgcrypto: Add option to revert to prior decryption behavior

От:
Noah Misch <noah@leadboat.com>
Дата:
pgcrypto: Add option to revert to prior decryption behavior

The previous commit raises an ERROR during PGP operations if OpenSSL
does not support the cipher in use. However, any existing messages
created with faulty encryption will no longer be accessible via
pgp_[sym|pub]_decrypt().

To help users out of this situation, add a new ignore-cipher-failure
option which reverts to the broken behavior during decryption only. A
faulty encryption wrapper, created by an OpenSSL configuration that does
not support the cipher, can then be stripped back off by that same
OpenSSL in order to safely reencrypt it. (Note that when OpenSSL does
support the cipher, corrupted messages will not be decrypted regardless
of the ignore-cipher-failure setting; this is unchanged.)

The new tests add a corrupted Blowfish message for both public- and
symmetric-key decryption, resulting in the following test matrix:

- Blowfish supported, default behavior:      fails to decrypt
- Blowfish supported, ignore-cipher-failure: fails to decrypt
- Blowfish unsupported, default behavior:    fails to load cipher
- Blowfish unsupported, ignore-cipher-failure: strips faulty encryption

The previous commit's change to the pubkey tests is expanded similarly:
correctly encrypted messages cannot be decrypted by an OpenSSL that does
not support the cipher, regardless of the option's setting, though the
failure mode will change.

Suggested-by: Noah Misch 
Reviewed-by: Daniel Gustafsson 
Reviewed-by: Noah Misch 
Security: CVE-2026-14663
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7eed42aa88053ce9319f249fc70a46181c026a4b
Author: Jacob Champion 

Modified Files
--------------
contrib/pgcrypto/expected/pgp-decrypt.out          | 26 ++++++++++++++++++
contrib/pgcrypto/expected/pgp-decrypt_1.out        | 30 ++++++++++++++++++++
contrib/pgcrypto/expected/pgp-info.out             |  3 +-
contrib/pgcrypto/expected/pgp-pubkey-decrypt.out   | 30 ++++++++++++++++++++
contrib/pgcrypto/expected/pgp-pubkey-decrypt_1.out | 30 ++++++++++++++++++++
contrib/pgcrypto/pgp-cfb.c                         | 21 ++++++++++----
contrib/pgcrypto/pgp-decrypt.c                     |  9 ++++--
contrib/pgcrypto/pgp-encrypt.c                     |  6 ++--
contrib/pgcrypto/pgp-pgsql.c                       |  2 ++
contrib/pgcrypto/pgp-pubkey.c                      |  9 +++++-
contrib/pgcrypto/pgp.c                             |  9 ++++++
contrib/pgcrypto/pgp.h                             |  7 ++++-
contrib/pgcrypto/sql/pgp-decrypt.sql               | 26 ++++++++++++++++++
contrib/pgcrypto/sql/pgp-pubkey-decrypt.sql        | 27 ++++++++++++++++++
doc/src/sgml/pgcrypto.sgml                         | 32 ++++++++++++++++++++++
15 files changed, 254 insertions(+), 13 deletions(-)

FAQ