Subject: Bug in copy binary of variable length fields

From: [email-masked] (Chris Bunting 95334)
Date: Mon, 27 Jul 92 19:47:11 -0700

Description: 
"copy binary" would crash if any of the attributes had a varlena stucture 
( eg text ). 
 
Source Files Changed: ~postgres/src/commands/copy.c 
 
Procedure Changed : CopyFrom() 
 
        line number : 378 
        was         : values[i] = (Datum) (ptr + 4); 
        now         : values[i] = (Datum) ptr; 
         
        line number : 379
        was         : LONGALIGN(ptr + * (unsigned long *) ptr + 4);
        now         : LONGALIGN(ptr + * (unsigned long *) ptr); 
         
Explanation: 
        The varlena type is 
        /* ---------------- 
         *      struct varlena 
         * ---------------- 
         */ 
         struct varlena { 
                long    vl_len;
                char    vl_dat[1]; 
           };
        the original source was skipping over the vl_len field.  
        When the code for copy was expecting to find the vl_len is was
        instead finding the fist four bytes of the vl_dat field.

---

From: Gregory Higgins <[email-masked]>
Date: Mon, 27 Jul 92 23:44:59 -0500

>        was         : values[i] = (Datum) (ptr + 4); 

Not to be too picky , but shouldn't the 4 have been a sizeof to begin with?

 -Gregory Higgins, Systems Manager, [email-masked]