Subject: Can't use GetAttributeByName for text type..

From: Xinguo Wei <[email-masked]>
Date: Thu, 5 Jan 1995 00:54:33 -0800 (PST)

Hi Postgresers,

I can't make the GetAttributeByName work for my text attribute.  The 
syntax I have is shown here,

char name[4];

strcpy(name,GetAttributeByName(t,"graphic_model", &isnull));

The attribute "graphic_model" is defined as text type.

The name array has all the garbage instead of the actual value.

What is the problem here?

My platform is Dec Alpha OSF/1.

Xinguo

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]".
   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/

---

From: [email-masked] (Paul M. Aoki)
Date: Thu, 05 Jan 95 09:12:17 -0800

> strcpy(name,GetAttributeByName(t,"graphic_model", &isnull));

"text" is not a C string.  "text" is

struct varlena {
        int32   vl_len;
        char    vl_dat[1];
};

[...]

typedef struct varlena text;

the data is not NUL-delimited.

(this is not particularly safe code in any case -- what happens if
graphic_model is null?)
--
  Paul M. Aoki          |  University of California at Berkeley
  [email-masked]  |  Dept. of EECS, Computer Science Division (#1776) 
                        |  Berkeley, CA 94720-1776