From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Expanding the use of FLEXIBLE_ARRAY_MEMBER for declarations like foo[1] |
Date: | 2015-02-16 20:51:22 |
Message-ID: | CAB7nPqQ62DYqufqqFEzz2MQNR0Tv+kAGByjjR-eXwxsmFVydFA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
In a lot of places in the code we have many structures doing
declarations of the type foo[1] to emulate variable length arrays.
Attached are a set of patches aimed at replacing that with
FLEXIBLE_ARRAY_MEMBER to prevent potential failures that could be
caused by compiler optimizations and improve report of static code
analyzers of the type Coverity (idea by Tom, patches from me):
- 0001 uses FLEXIBLE_ARRAY_MEMBER in a bunch of trivial places (at
least check-world does not complain)
- 0002 does the same for catalog tables
- 0003 changes varlena in c.h. This is done as a separate patch
because this needs some other modifications as variable-length things
need to be placed at the end of structures, because of:
-- rolpassword that should be placed as the last field of pg_authid
(and shouldn't there be CATALOG_VARLEN here??)
-- inv_api.c uses bytea in an internal structure without putting it at
the end of the structure. For clarity I think that we should just use
a bytea pointer and do a sufficient allocation for the duration of the
lobj manipulation.
-- Similarly, tuptoaster.c needed to be patched for toast_save_datum
There are as well couple of things that are not changed on purpose:
- in namespace.h for FuncCandidateList. I tried manipulating it but it
resulted in allocation overflow in PortalHeapMemory
- I don't think that the t_bits fields in htup_details.h should be
updated either.
Regards,
--
Michael
Attachment | Content-Type | Size |
---|---|---|
0001-First-cut-with-FLEXIBLE_ARRAY_MEMBER.patch | text/x-diff | 25.4 KB |
0002-Use-FLEXIBLE_ARRAY_MEMBER-in-catalog-tables.patch | text/x-diff | 15.5 KB |
0003-Update-varlena-in-c.h-to-use-FLEXIBLE_ARRAY_MEMBER.patch | text/x-diff | 8.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2015-02-16 21:34:07 | Re: Perl coding error in msvc build system? |
Previous Message | Jim Nasby | 2015-02-16 18:38:21 | Re: Allow "snapshot too old" error, to prevent bloat |