postgres.git / summary / log / commit / refs

commit    405635ad61d22b9d7a69ef53eb4fbcb2188936da
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sat Jan 09 21:58:33 2016 +0000

    Clean up some lack-of-STRICT issues in the core code, too.
    
    A scan for missed proisstrict markings in the core code turned up
    these functions:
    
    brin_summarize_new_values
    pg_stat_reset_single_table_counters
    pg_stat_reset_single_function_counters
    pg_create_logical_replication_slot
    pg_create_physical_replication_slot
    pg_drop_replication_slot
    
    The first three of these take OID, so a null argument will normally look
    like a zero to them, resulting in "ERROR: could not open relation with OID
    0" for brin_summarize_new_values, and no action for the pg_stat_reset_XXX
    functions.  The other three will dump core on a null argument, though this
    is mitigated by the fact that they won't do so until after checking that
    the caller is superuser or has rolreplication privilege.
    
    In addition, the pg_logical_slot_get/peek[_binary]_changes family was
    intentionally marked nonstrict, but failed to make nullness checks on all
    the arguments; so again a null-pointer-dereference crash is possible but
    only for superusers and rolreplication users.
    
    Add the missing ARGISNULL checks to the latter functions, and mark the
    former functions as strict in pg_proc.  Make that change in the back
    branches too, even though we can't force initdb there, just so that
    installations initdb'd in future won't have the issue.  Since none of these
    bugs rise to the level of security issues (and indeed the pg_stat_reset_XXX
    functions hardly misbehave at all), it seems sufficient to do this.
    
    In addition, fix some order-of-operations oddities in the slot_get_changes
    family, mostly cosmetic, but not the part that moves the function's last
    few operations into the PG_TRY block.  As it stood, there was significant
    risk for an error to exit without clearing historical information from
    the system caches.
    
    The slot_get_changes bugs go back to 9.4 where that code was introduced.
    Back-patch appropriate subsets of the pg_proc changes into all active
    branches, as well.


src/include/catalog/pg_proc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index e20e41b112c..4b788215ef5 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -2661,9 +2661,9 @@ DATA(insert OID = 2274 ( pg_stat_reset PGNSP PGUID 12 1 0 0 f f f f f v 0 0 DESCR("statistics: reset collected statistics for current database"); DATA(insert OID = 3775 ( pg_stat_reset_shared PGNSP PGUID 12 1 0 0 f f f f f v 1 0 2278 "25" _null_ _null_ _null_ _null_ pg_stat_reset_shared _null_ _null_ _null_ )); DESCR("statistics: reset collected statistics shared across the cluster"); -DATA(insert OID = 3776 ( pg_stat_reset_single_table_counters PGNSP PGUID 12 1 0 0 f f f f f v 1 0 2278 "26" _null_ _null_ _null_ _null_ pg_stat_reset_single_table_counters _null_ _null_ _null_ )); +DATA(insert OID = 3776 ( pg_stat_reset_single_table_counters PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ pg_stat_reset_single_table_counters _null_ _null_ _null_ )); DESCR("statistics: reset collected statistics for a single table or index in the current database"); -DATA(insert OID = 3777 ( pg_stat_reset_single_function_counters PGNSP PGUID 12 1 0 0 f f f f f v 1 0 2278 "26" _null_ _null_ _null_ _null_ pg_stat_reset_single_function_counters _null_ _null_ _null_ )); +DATA(insert OID = 3777 ( pg_stat_reset_single_function_counters PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "26" _null_ _null_ _null_ _null_ pg_stat_reset_single_function_counters _null_ _null_ _null_ )); DESCR("statistics: reset collected statistics for a single function in the current database"); DATA(insert OID = 1946 ( encode PGNSP PGUID 12 1 0 0 f f f t f i 2 0 25 "17 25" _null_ _null_ _null_ _null_ binary_encode _null_ _null_ _null_ )); [parent: fe2578568e76]