public inbox for [email protected]
help / color / mirror / Atom feedFrom: Hongxu Ma <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: PSQL error: total cell count of XXX exceeded
Date: Sat, 26 Aug 2023 03:29:44 +0000
Message-ID: <TYBP286MB0351B057B101C90D7C1239E6B4E2A@TYBP286MB0351.JPNP286.PROD.OUTLOOK.COM> (raw)
Hi Hackers,
When I tried to select a big amount of rows, psql complains a error "Cannot add cell to table content: total cell count of 905032704 exceeded."
Here are the reproduce steps:
```
interma=# select version();
version
-----------------------------------------------------------------------------------------
PostgreSQL 12.13 on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
(1 row)
interma=# create table t26(a int,b int,c int,d int,e int,f int,g int,h int,i int,j int,k int,l int,m int,n int,o int,p int,q int,r int,s int,t int ,u int,v int,w int,x int,y int,z int);
CREATE TABLE
interma=# insert into t26 select generate_series(1,200000000);
INSERT 0 200000000
interma=# select * from t26;
Cannot add cell to table content: total cell count of 905032704 exceeded.
```
I checked the related code, and root cause is clear:
```
// in printTableAddCell()
if (content->cellsadded >= content->ncolumns * content->nrows)
report this error and exit
// cellsadded is long type, but ncolumns and nrows are int
// so, it's possible overflow the int value here.
// using a test program to verify:
int rows = 200000000;
int cols = 26;
printf("%d*%d = %d\n", rows,cols, rows*cols);
output:
2,0000,0000*26 = 9,0503,2704 // overflow and be truncated into int value here
```
Based on it, I think it's a bug. We should use long for ncolumns and nrows and give a more obvious error message here.
My version is 12.13, and I think the latest code also exists this issue: issue: https://github.com/postgres/postgres/blob/1a4fd77db85abac63e178506335aee74625f6499/src/fe_utils/prin...
Any thoughts? or some other hidden reasons?
Thanks.
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: PSQL error: total cell count of XXX exceeded
In-Reply-To: <TYBP286MB0351B057B101C90D7C1239E6B4E2A@TYBP286MB0351.JPNP286.PROD.OUTLOOK.COM>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox