• Tom Lane's avatar
    Rationalize the APIs of array element/slice access functions. · e983c4d1
    Tom Lane authored
    The four functions array_ref, array_set, array_get_slice, array_set_slice
    have traditionally declared their array inputs and results as being of type
    "ArrayType *".  This is a lie, and has been since Berkeley days, because
    they actually also support "fixed-length array" types such as "name" and
    "point"; not to mention that the inputs could be toasted.  These values
    should be declared Datum instead to avoid confusion.  The current coding
    already risks possible misoptimization by compilers, and it'll get worse
    when "expanded" array representations become a valid alternative.
    
    However, there's a fair amount of code using array_ref and array_set with
    arrays that *are* known to be ArrayType structures, and there might be more
    such places in third-party code.  Rather than cluttering those call sites
    with PointerGetDatum/DatumGetArrayTypeP cruft, what I did was to rename the
    existing functions to array_get_element/array_set_element, fix their
    signatures, then reincarnate array_ref/array_set as backwards compatibility
    wrappers.
    
    array_get_slice/array_set_slice have no such constituency in the core code,
    and probably not in third-party code either, so I just changed their APIs.
    e983c4d1
execQual.c 157 KB