Re: Tuple too big - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Tuple too big
Date
Msg-id 199907030200.WAA23471@candle.pha.pa.us
Whole thread Raw
List pgsql-hackers
> I've encountered a strange behavior of the VACUUM ANALYZE command.
> It seems that this command works only if the size of a text field
> does not exceed approximately 4050 bytes! So the real limit on 
> tuple size is a half of the max tuple size. I've checked this effect
> on Postgres 6.4.2 (Sparc Solaris 2.5.1) and Postgres 6.5 (SUSE 6.1 
> Linux, kernel 2.2.5). Is this a bug or known feature?
> The python script used to reproduce this problem and results for 
> v6.4.2 and v6.5 are follows.
> 

OK, looks like the new code works:test=> create table test (x char(2000), y char(2000), z char(2000))\gCREATEtest=>
insertinto test values ('1','2','3');ERROR:  Tuple is too big: size 6044, max size 4044test=> create table test2 (x
varchar(2000),y varchar(2000), zvarchar(2000))\gCREATEtest=> insert into test2 values ('1','2','3');INSERT 21303 1
 

char() is fixed length, while varchar() is variable.  Now, we could
prevent creation of the first table, but not the second because only the
inserted data will show if it over the limit.  Much easier just to test
in one place.

Here is the new patch:

---------------------------------------------------------------------------

Index: hio.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/access/heap/hio.c,v
retrieving revision 1.20
retrieving revision 1.22
diff -c -r1.20 -r1.22
*** hio.c    1999/05/25 16:07:07    1.20
--- hio.c    1999/07/03 01:56:16    1.22
***************
*** 16,21 ****
--- 16,22 ----  #include <storage/bufpage.h> #include <access/hio.h>
+ #include <access/htup.h> #include <access/heapam.h> #include <storage/bufmgr.h> #include <utils/memutils.h>
***************
*** 164,169 ****
--- 165,173 ----         if (len > PageGetFreeSpace(pageHeader))             elog(ERROR, "Tuple is too big: size %d",
len);    }
 
+ 
+     if (len > MaxTupleSize)
+         elog(ERROR, "Tuple is too big: size %d, max size %d", len, MaxTupleSize);      if (!relation->rd_myxactonly)
      UnlockPage(relation, 0, ExclusiveLock);
 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: Tuple too big
Next
From: Wayne Piekarski
Date:
Subject: Re: [HACKERS] Update on my 6.4.2 progress