Before posting patches, it would be very helpful to run at least 'make
check' and 'make check-world' on a build configured with
--enable-cassert and --enable-tap-tests, as this often helps to catch
issues early.
A few additional moments:
1. If we determine that statistics already exists, it is not enough to
only call vac_close_indexes(). We also need to make sure that everything
else is freed properly: memory contexts, restored privileges, etc.
Please take a look at the end of do_analyze_rel() for the full cleanup
sequence.
2. Static functions should be also have their declarations placed at the
top of the file, following the usual style.
3. The expression (params.options & VACOPT_MISSING_STATS_ONLY) appears
multiple times. It might be simpler to introduce a local variable such
as 'missing_stats_only' and use it instead.
4. The message about skipping analyzing for a relation should follow the
same logging pattern as the message about analyzing a relation, i.e.
using 'verbose ? INFO : LOG'. See the end of the function for reference.
--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/