Fix ISSN output truncation when the issue code is nonzero

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Jonah Shafran <jonahshafran(at)gmail(dot)com>
Subject: Fix ISSN output truncation when the issue code is nonzero
Date: 2026-11-18 08:26:56
Message-ID: 3c6b891b-89c9-44d0-8515-5c532e5fdae5@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

As reported in [1], a 13-digit issn with a nonzero issue publication
code is currently displayed in its 8-digit short form, which drops that
code. Values that differ only in the issue code are therefore displayed
identically while comparing unequal:

== master ==

psql (20devel)
Type "help" for help.

postgres=# create extension isn;
CREATE EXTENSION
postgres=# with j (v1,v2) as (
values ('12345679'::issn, '9771234567898'::issn)
)
select v1,v2,v1=v2 from j;
v1 | v2 | ?column?
-----------+-----------+----------
1234-5679 | 1234-5679 | f
(1 row)

The attached patch adds a guard in ean2ISSN to keep the full issn in
case the given isn has an issue publication code, therefore avoiding
truncation.

== patched ==

psql (20devel)
Type "help" for help.

postgres=# create extension isn;
CREATE EXTENSION
postgres=# with j (v1,v2) as (
values ('12345679'::issn, '9771234567898'::issn)
)
select v1,v2,v1=v2 from j;
v1 | v2 | ?column?
-----------+-------------------+----------
1234-5679 | 977-1234-567-89-8 | f
(1 row)

Best, Jim

1 -
https://www.postgresql.org/message-id/4e6c2fc9-5389-4958-a432-bb0ee5348ad0%40uni-muenster.de

Attachment Content-Type Size
v1-0001-Fix-ISSN-output-truncation-when-the-issue-code-is.patch text/x-patch 2.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Akshay Joshi 2026-11-18 08:32:40 Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements
Previous Message Alexandre Felipe 2026-11-18 08:25:32 Re: pg_regress: schedule multi-line test groups