Re: Re: What's the prefix?

From: "jacktby(at)gmail(dot)com" <jacktby(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Re: What's the prefix?
Date: 2023-02-27 02:04:09
Message-ID: 2023022710040863979037@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


From: David G. Johnston
Date: 2023-02-27 00:27
To: jacktby(at)gmail(dot)com
CC: pgsql-hackers
Subject: Re: What's the prefix?
On Sun, Feb 26, 2023 at 9:16 AM jacktby(at)gmail(dot)com <jacktby(at)gmail(dot)com> wrote:
use these sqls:
create table t(a text);
insert into t values('a');
select lp,lp_len,t_data from heap_page_items(get_raw_page('t',0));
lp | lp_len | t_data
----+--------+--------
1 | 26 | \x0561
as you can see, the 61 is 'a', so what's the 05??? strange.

text is variable length so there is header information built into the datatype representation that indicates how long the content is.

David J.

No, this is the varlena struct:
struct varlena
{
char vl_len_[4]; /* Do not touch this field directly! */
char vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */
};
when I insert 'a', this struct will be {
vl_len : 00 00 00 05
vl_dat: 'a'
}
the t_data should be \x0000000561, but it's \x0561? strange
----------------------------------------------------------------------------------
jacktby(at)gmail(dot)com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-02-27 02:18:55 Re: What's the prefix?
Previous Message Justin Pryzby 2023-02-27 02:00:30 Re: meson vs make: missing/inconsistent ENV