Re: How to Know the number of attrs?

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: jacktby jacktby <jacktby(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: How to Know the number of attrs?
Date: 2023-09-24 13:38:28
Message-ID: zey2jtdj2kvitqgepucrnms45qiwd3k3gzpexihhbtxme5s22n@v7wzkkxsg3uz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2023-09-24 20:56 +0800, jacktby jacktby wrote:
> typedef struct TupleDescData
> {
> int natts; /* number of attributes in the tuple */
> Oid tdtypeid; /* composite type ID for tuple type */
> int32 tdtypmod; /* typmod for tuple type */
> int tdrefcount; /* reference count, or -1 if not counting */
> TupleConstr *constr; /* constraints, or NULL if none */
> /* attrs[N] is the description of Attribute Number N+1 */
> FormData_pg_attribute attrs[FLEXIBLE_ARRAY_MEMBER];
> } TupleDescData;
>
> Hi, the attrs use FLEXIBLE_ARRAY_MEMBER, so which API should I use to
> get the real length of this array?

Use the natts field of TupleDescData.

--
Erik

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2023-09-24 16:45:21 Re: Eager page freeze criteria clarification
Previous Message jacktby jacktby 2023-09-24 12:57:33 How to Know the number of attrs?