Bugfix for bpchar - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Bugfix for bpchar
Date
Msg-id m0y0SLk-000BFRC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
List pgsql-hackers
Hi,

    after spending 3 hours in gdb I found it :-)

    Symptom:
        select  from  a  table  with  attrs  (a  int, b char(20))
        crashed in bpcharout() (palloc of -1 bytes). But a  table
        with attrs (a int, b varchar(20)) worked.

    Bug location:
        Function  nocachegetattr()  in  access/common/heaptuple.c
        line 557.  Really surprising - and really hard to find  -
        phew.


Until later, Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #


*** heaptuple.c    Thu Feb  5 15:21:50 1998
--- heaptuple.c.old    Thu Feb  5 15:21:39 1998
***************
*** 554,560 ****
          while (att[j]->attcacheoff > 0)
              j++;

!         if (!VARLENA_FIXED_SIZE(att[j - 1]))
              off = att[j - 1]->attcacheoff + att[j - 1]->attlen;
          else
              off = att[j - 1]->attcacheoff + att[j - 1]->atttypmod;
--- 554,560 ----
          while (att[j]->attcacheoff > 0)
              j++;

!         if (!VARLENA_FIXED_SIZE(att[j]))
              off = att[j - 1]->attcacheoff + att[j - 1]->attlen;
          else
              off = att[j - 1]->attcacheoff + att[j - 1]->atttypmod;

pgsql-hackers by date:

Previous
From: pghackers@sunsystem5.informatik.tu-muenchen.de
Date:
Subject: ...
Next
From: Michael Meskes
Date:
Subject: Preprocessor