Thread: pg_type populated incorrectly in some cases?

pg_type populated incorrectly in some cases?

From
Maurice Gittens
Date:
Hi,

In include/catalog/pg_type.h I've noticed the following code.

<Code>
CATALOG(pg_type) BOOTSTRAP
{
    NameData    typname;
    Oid            typowner;
    int2        typlen;

    /*
     * typlen is the number of bytes we use to represent a value of this
     * type, e.g. 4 for an int4.  But for a variable length type, typlen
     * is -1.

    ...
</Code>

The pg_type catalog is then populated with lines like the following.

<Code>
DATA(insert OID = 71 (    pg_type         PGUID 1 1 t b t \054 1247 0 foo bar foo bar c _null_));
DATA(insert OID = 75 (    pg_attribute PGUID 1 1 t b t \054 1249 0 foo bar foo bar c _null_));
DATA(insert OID = 81 (    pg_proc         PGUID 1 1 t b t \054 1255 0 foo bar foo bar c _null_));
DATA(insert OID = 83 (    pg_class     PGUID 1 1 t b t \054 1259 0 foo bar foo bar c _null_));

</Code>

Notice that the type length for types like pg_class have the value of one (1)?
I would have expected them to the same length as an oid.
Am I just seeing things?

Thanks with regards from Maurice


Re: [HACKERS] pg_type populated incorrectly in some cases?

From
Bruce Momjian
Date:
>
> Hi,
>
> In include/catalog/pg_type.h I've noticed the following code.
>
> <Code>
> CATALOG(pg_type) BOOTSTRAP
> {
>     NameData    typname;
>     Oid            typowner;
>     int2        typlen;
>
>     /*
>      * typlen is the number of bytes we use to represent a value of this
>      * type, e.g. 4 for an int4.  But for a variable length type, typlen
>      * is -1.
>
>     ...
> </Code>
>
> The pg_type catalog is then populated with lines like the following.
>
> <Code>
> DATA(insert OID = 71 (    pg_type         PGUID 1 1 t b t \054 1247 0 foo bar foo bar c _null_));
> DATA(insert OID = 75 (    pg_attribute PGUID 1 1 t b t \054 1249 0 foo bar foo bar c _null_));
> DATA(insert OID = 81 (    pg_proc         PGUID 1 1 t b t \054 1255 0 foo bar foo bar c _null_));
> DATA(insert OID = 83 (    pg_class     PGUID 1 1 t b t \054 1259 0 foo bar foo bar c _null_));
>
> </Code>
>
> Notice that the type length for types like pg_class have the value of one (1)?
> I would have expected them to the same length as an oid.
> Am I just seeing things?
>
> Thanks with regards from Maurice
>
>
>


I believe these should be -1, and I have set them to that.  typprtlen is
not used for any purpose currently, but it pads the other int2 field, so
it is not taking any space, and someday may be useful.


--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)