Re: PSQL error: total cell count of XXX exceeded

From: Hongxu Ma <interma(at)outlook(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PSQL error: total cell count of XXX exceeded
Date: 2023-09-13 07:31:54
Message-ID: TYBP286MB0351CA77974AFE5A689E3369B4F0A@TYBP286MB0351.JPNP286.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

After double check, looks `int64` of src/include/c.h is the proper type for it.
Uploaded the v4 patch to fix it.
Thanks.

________________________________
From: Hongxu Ma <interma(at)outlook(dot)com>
Sent: Wednesday, September 13, 2023 10:22
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>; Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PSQL error: total cell count of XXX exceeded

Thanks for pointing that, I did miss some other "ncols * nrows" places. Uploaded v3 patch to fix them.

As for the Windows, I didn't test it before but I think it should also have the issue (and happens more possible since ​`cellsadded` is also a long type).
My fix idea is simple: define a common long64 type for it.
I referred MSDN: only `LONGLONG` and `LONG64` are 64 bytes. And I assume Postgres should already have a similar type, but only found `typedef long int int64` in src/include/c.h, looks it's not a proper choose.
@Michael Paquier<mailto:michael(at)paquier(dot)xyz>, could you help to give some advices here (which type should be used? or should define a new one?). Thank you very much.

________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Tuesday, September 12, 2023 12:19
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Hongxu Ma <interma(at)outlook(dot)com>; Jelte Fennema <postgres(at)jeltef(dot)nl>; David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>; PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PSQL error: total cell count of XXX exceeded

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Tue, Sep 12, 2023 at 02:39:55AM +0000, Hongxu Ma wrote:
> + long total_cells;

> long is 4 bytes on Windows, and 8 bytes basically elsewhere. So you
> would still have the same problem on Windows, no?

More to the point: what about the multiplication in printTableInit?
The cat's been out of the bag for quite some time before we get to
printTableAddCell.

I'm more than a bit skeptical about trying to do something about this,
simply because this range of query result sizes is far past what is
practical. The OP clearly hasn't tested his patch on actually
overflowing query results, and I don't care to either.

regards, tom lane

Attachment Content-Type Size
v4-0001-Using-int64-type-for-the-number-of-total-cells.patch application/octet-stream 3.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2023-09-13 08:22:29 Re: [dynahash] do not refill the hashkey after hash_search
Previous Message Alexander Kukushkin 2023-09-13 07:21:35 Re: pg_rewind WAL segments deletion pitfall