| From: | Jonah Shafran <jonahshafran(at)gmail(dot)com> |
|---|---|
| To: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
| Cc: | Daniel Gustafsson <daniel(at)yesql(dot)se>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: ISBN range table |
| Date: | 2026-11-17 23:39:23 |
| Message-ID: | CAA2HNvSgmooVXLp+o5YrP0Ao9wO6a8C25t+ro-Gkhtg8D8xA1w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
That approach makes sense to me, the one nitpick would be adding a comment
to the final patch:
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
index a1d2f26158a..0313a8aa838 100644
--- a/contrib/isn/isn.c
+++ b/contrib/isn/isn.c
@@ -472,6 +472,15 @@ static inline void
ean2ISSN(char *isn)
{
unsigned check;
+ char digits[MAXEAN13LEN + 1];
+
+ /*
+ * If the issue publication code is non-zero,
+ * we shouldn't perform any truncation
+ */
+ dehyphenate(digits, isn);
+ if(strncmp(digits+10, "00", 2) != 0)
+ return;
/* the number should come in this format: 977-0000-000-00-0 */
/* Strip the first part, crop, and calculate the new check digit */
I imagine this fix would probably make sense as a separate bug fix patch.
Thanks,
Jonah
On Tue, Nov 17, 2026 at 2:09 AM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
>
> On 17/11/2026 02:39, Jonah Shafran wrote:
> > I agree with your assessment that this is unrelated to the patch- I was
> > able to reproduce this back to Postgres 17 (the oldest version I had
> > running on hand).
>
>
> I guess it's been like this forever -- I could reproduce it in PG11:
>
> psql (11.22 (Debian 11.22-1.pgdg110+1))
> Geben Sie »help« für Hilfe ein.
>
> postgres=# create extension isn;
> CREATE EXTENSION
> postgres=# with j (v1,v2) as (
> values ('12345679'::issn, '9771234567898'::issn)
> )
> select v1,v2,v1=v2,v1::text=v2::text from j;
> v1 | v2 | ?column? | ?column?
> -----------+-----------+----------+----------
> 1234-5679 | 1234-5679 | f | t
> (1 Zeile)
>
>
> > As far as what is going on, it looks like ISSNs are
> > specified to use the short output format (isn_out, see isn--1.1.sql line
> > 154), however, ISSNs don't seem to get normalized to one canonical form
> > when being read in by issn_in. I wasn't able to determine how ISBNs are
> > being handled differently with the time I had today, but it looks like
> > something in string2ean must be processing the ISBN and ISSN strings
> > differently.
>
>
> What about making ean2ISSN return early when the issue pub code is not
> 00? e.g.
>
> diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
> index a1d2f26158a..141d05d910e 100644
> --- a/contrib/isn/isn.c
> +++ b/contrib/isn/isn.c
> @@ -472,6 +472,11 @@ static inline void
> ean2ISSN(char *isn)
> {
> unsigned check;
> + char digits[MAXEAN13LEN + 1];
> +
> + dehyphenate(digits, isn);
> + if (strncmp(digits + 10, "00", 2) != 0)
> + return;
>
> /* the number should come in this format: 977-0000-000-00-0 */
> /* Strip the first part, crop, and calculate the new check digit */
>
>
>
> psql (20devel)
> Type "help" for help.
>
> postgres=# with j (v1,v2) as (
> values ('12345679'::issn, '9771234567898'::issn)
> )
> select v1,v2,v1=v2,v1::text=v2::text from j;
> v1 | v2 | ?column? | ?column?
> -----------+-------------------+----------+----------
> 1234-5679 | 977-1234-567-89-8 | f | f
> (1 row)
>
>
> Best, Jim
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ajin Cherian | 2026-11-17 23:48:01 | Re: [PATCH] Preserve replication origin OIDs in pg_upgrade |
| Previous Message | surya poondla | 2026-11-17 23:19:26 | Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts |