timescaledb/test/sql/guc_options.sql
Mats Kindahl 34b5ef4d18 Add debug printout for optimizer
Debug printouts are added at two locations:

* Inside `get_foreign_upper_paths` a notice with the existing paths is
  send back together with the stage if the `show_upper` is set to show
  the stage.

* Inside `set_rel_pathlist` a notice is printed with the existing paths
  if the `show_rel` debug flag is set.

The debug printouts are sent back to the client as debug messages
(`DEBUG2`), allowing developers to quickly experiment and interactively
see what effect different statements has with the respect to the paths
generated.

In addition, the handling of `debug_optimizer_flag` was not correct and
is fixed here.

* If no `=` was provided to `show_upper`, it triggered a segmentation
  fault.

* If the flag was reset, the internal data structure was not updated.

* If just one flag was updated in a `SET` command, the other flag was
  kept intact.
2020-05-27 17:31:09 +02:00

48 lines
2.4 KiB
SQL

-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
\c :TEST_DBNAME :ROLE_SUPERUSER
SET timescaledb.debug_optimizer_flags = '';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=final';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=fin';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=fin,win';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=*,fin,win';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=*';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=win:show_rel';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = '"show_upper=win":show_rel';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_upper=win : show_rel';
SHOW timescaledb.debug_optimizer_flags;
SET timescaledb.debug_optimizer_flags = 'show_rel:show_upper=win';
SHOW timescaledb.debug_optimizer_flags;
-- These should all fail
\set ON_ERROR_STOP 0
SET timescaledb.debug_optimizer_flags = NULL;
SET timescaledb.debug_optimizer_flags = 'invalid';
SET timescaledb.debug_optimizer_flags = '"unmatched quote:';
SET timescaledb.debug_optimizer_flags = 'space between';
SET timescaledb.debug_optimizer_flags = 'space between:';
SET timescaledb.debug_optimizer_flags = 'show_rel:invalid';
SET timescaledb.debug_optimizer_flags = 'invalid:show_rel';
SET timescaledb.debug_optimizer_flags = 'show_upper:*';
SET timescaledb.debug_optimizer_flags = 'show_upper=xxx';
SET timescaledb.debug_optimizer_flags = 'show_upper=fin,xxx';
SET timescaledb.debug_optimizer_flags = 'show_upper=xxx,fin';
SET timescaledb.debug_optimizer_flags = 'show_upper=win,xxx,fin';
SET timescaledb.debug_optimizer_flags = 'show_upper=xxx';
SET timescaledb.debug_optimizer_flags = 'show_upper=*,xxx';
SET timescaledb.debug_optimizer_flags = 'show_upper=xxx,*';
SET timescaledb.debug_optimizer_flags = 'show_upper=xxx,*,yyy';
SET timescaledb.debug_optimizer_flags = 'show_upper=supercalifragilisticexpialidochious';
SET timescaledb.debug_optimizer_flags = 'show_upper=super,califragilisticexpialidochious';
\set ON_ERROR_STOP 1