| From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
|---|---|
| To: | Mark Dilger <mark(at)port25(dot)com> |
| Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: thinko in convertToJsonb() |
| Date: | 2014-12-10 04:48:39 |
| Message-ID: | CAB7nPqTQciS98NCdZ4ZzqGjJ+4N1yvKyqGLdufHJHAu7_urYQA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Dec 9, 2014 at 11:11 AM, Mark Dilger <mark(at)port25(dot)com> wrote:
> The call:
>
> reserveFromBuffer(&buffer, sizeof(VARHDRSZ))
>
> is assuming that the size of varlena header is the same
> size as the type used to return that size, which happens
> to be so, but someone could easily change that macro
> to:
>
> #define VARHDRSZ ((int64) sizeof(int32))
>
> And you'd want to reserve sizeof(int32), not sizeof(int64)
> in convertToJsonb.
>
> Perhaps the code really meant to say:
>
> reserveFromBuffer(&buffer, VARHDRSZ)
Good catch! The code is indeed incorrect. Attached is a one-line patch
addressing that, I guess someone is going to pick up that sooner or
later.
--
Michael
| Attachment | Content-Type | Size |
|---|---|---|
| 20141210_jsonb_varlena_header.patch | application/octet-stream | 460 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2014-12-10 05:11:42 | Re: logical column ordering |
| Previous Message | Amit Kapila | 2014-12-10 03:46:30 | Re: On partitioning |