Change the way string relopts are allocated.

Heikki Linnakangas <heikki.linnakangas@iki.fi>

Commit: 77949a2913b3cbaa7b2e2a73f014d541e251f18b
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2011-08-09T12:25:44Z
Releases: 9.2.0
Change the way string relopts are allocated.

Don't try to allocate the default value for a string relopt in the same
palloc chunk as the relopt_string struct. That didn't work too well if you
added a built-in string relopt in the stringRelOpts array, as it's not
possible to have an initializer for a variable length struct in C. This
makes the code slightly simpler too.

While we're at it, move the call to validator function in
add_string_reloption to before the allocation, so that if someone does pass
a bogus default value, we don't leak memory.

Files

PathChange+/−
src/backend/access/common/reloptions.c modified +12 −27
src/include/access/reloptions.h modified +1 −1