From d0f75bd8a6e7085f8569bec582a4ec655ac420bb Mon Sep 17 00:00:00 2001 From: timothy-e Date: Wed, 16 Oct 2024 17:10:00 -0400 Subject: [PATCH] [#24299] YSQL: fix TestPgRegressYbBitmapScans Summary: https://github.com/yugabyte/yugabyte-db/issues/24384 identifies an issue where a `name_col LIKE text_val` condition cannot be pushed down to DocDB because, with the upgrade to pg15, the condition is broken into `name_col > text_val_prefix AND name_col < text_val_prefix2`. Previously, on YB pg11, the condition would have been broken into `name_col > text_val_prefix::name AND ...`, which could be pushed down to DocDB. This does not result in a correctness issue, because the rows get rechecked later. This change causes the bitmap scan system tests to fail. To fix this test in the meantime, use the new row counts. Also, update the results to account for the new roles introduced by pg15. When we fix #24384, this test will need to be updated again. Jira: DB-13188 Test Plan: ``` ./yb_build.sh release --java-test 'org.yb.pgsql.TestPgRegressYbBitmapScans' ``` ``` grep "Bitmap" pg15_tests/passing_tests.tsv | pg15_tests/run_tests.sh ``` Reviewers: amartsinchyk, tnayak Reviewed By: amartsinchyk Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D38929 --- .../expected/yb_bitmap_scans_system.out | 96 ++++++++++--------- .../regress/sql/yb_bitmap_scans_system.sql | 4 +- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/postgres/src/test/regress/expected/yb_bitmap_scans_system.out b/src/postgres/src/test/regress/expected/yb_bitmap_scans_system.out index 692609eb4342..1294db1e45aa 100644 --- a/src/postgres/src/test/regress/expected/yb_bitmap_scans_system.out +++ b/src/postgres/src/test/regress/expected/yb_bitmap_scans_system.out @@ -5,60 +5,66 @@ SET yb_explain_hide_non_deterministic_fields = true; SET yb_enable_bitmapscan = true; SET enable_bitmapscan = true; /*+ BitmapScan(pg_authid) */ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF) -SELECT * FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Sort (actual rows=11 loops=1) +SELECT rolname FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------- + Sort (actual rows=15 loops=1) Sort Key: rolname Sort Method: quicksort - -> YB Bitmap Table Scan on pg_authid (actual rows=11 loops=1) + -> YB Bitmap Table Scan on pg_authid (actual rows=15 loops=1) Storage Filter: ((rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) - -> BitmapOr (actual rows=11 loops=1) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=8 loops=1) - Index Cond: ((rolname >= 'pg'::name) AND (rolname < 'ph'::name)) + Recheck Cond: (((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) OR ((rolname >= 'yb'::text) AND (rolname < 'yc'::text))) + -> BitmapOr (actual rows=15 loops=1) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=15 loops=1) + Index Cond: ((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) Storage Index Filter: ((rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=3 loops=1) - Index Cond: ((rolname >= 'yb'::name) AND (rolname < 'yc'::name)) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=15 loops=1) + Index Cond: ((rolname >= 'yb'::text) AND (rolname < 'yc'::text)) Storage Index Filter: ((rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) -(12 rows) +(13 rows) /*+ BitmapScan(pg_authid) */ -SELECT * FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; - rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolbypassrls | rolconnlimit | rolpassword | rolvaliduntil ----------------------------+----------+------------+---------------+-------------+-------------+----------------+--------------+--------------+-------------+--------------- - pg_execute_server_program | f | t | f | f | f | f | f | -1 | | - pg_monitor | f | t | f | f | f | f | f | -1 | | - pg_read_all_settings | f | t | f | f | f | f | f | -1 | | - pg_read_all_stats | f | t | f | f | f | f | f | -1 | | - pg_read_server_files | f | t | f | f | f | f | f | -1 | | - pg_signal_backend | f | t | f | f | f | f | f | -1 | | - pg_stat_scan_tables | f | t | f | f | f | f | f | -1 | | - pg_write_server_files | f | t | f | f | f | f | f | -1 | | - yb_db_admin | f | f | f | f | f | f | f | -1 | | - yb_extension | f | t | f | f | f | f | f | -1 | | - yb_fdw | f | t | f | f | f | f | f | -1 | | -(11 rows) +SELECT rolname FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; + rolname +--------------------------- + pg_checkpoint + pg_database_owner + pg_execute_server_program + pg_monitor + pg_read_all_data + pg_read_all_settings + pg_read_all_stats + pg_read_server_files + pg_signal_backend + pg_stat_scan_tables + pg_write_all_data + pg_write_server_files + yb_db_admin + yb_extension + yb_fdw +(15 rows) /*+ BitmapScan(pg_authid) */ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF) SELECT spcname FROM pg_tablespace WHERE spcowner NOT IN ( SELECT oid FROM pg_roles WHERE rolname = 'postgres' OR rolname LIKE 'pg_%' OR rolname LIKE 'yb_%'); - QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Seq Scan on pg_tablespace (actual rows=0 loops=1) Filter: (NOT (hashed SubPlan 1)) Rows Removed by Filter: 2 SubPlan 1 - -> YB Bitmap Table Scan on pg_authid (actual rows=12 loops=1) + -> YB Bitmap Table Scan on pg_authid (actual rows=16 loops=1) Storage Filter: ((rolname = 'postgres'::name) OR (rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) - -> BitmapOr (actual rows=12 loops=1) + Recheck Cond: ((rolname = 'postgres'::name) OR ((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) OR ((rolname >= 'yb'::text) AND (rolname < 'yc'::text))) + -> BitmapOr (actual rows=16 loops=1) -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=1 loops=1) Index Cond: (rolname = 'postgres'::name) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=8 loops=1) - Index Cond: ((rolname >= 'pg'::name) AND (rolname < 'ph'::name)) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=16 loops=1) + Index Cond: ((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) Storage Index Filter: ((rolname = 'postgres'::name) OR (rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=3 loops=1) - Index Cond: ((rolname >= 'yb'::name) AND (rolname < 'yc'::name)) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=16 loops=1) + Index Cond: ((rolname >= 'yb'::text) AND (rolname < 'yc'::text)) Storage Index Filter: ((rolname = 'postgres'::name) OR (rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) -(15 rows) +(16 rows) /*+ BitmapScan(pg_authid) */ SELECT spcname FROM pg_tablespace WHERE spcowner NOT IN ( SELECT oid FROM pg_roles WHERE rolname = 'postgres' OR rolname LIKE 'pg_%' OR rolname LIKE 'yb_%'); @@ -69,22 +75,24 @@ SELECT * FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER B SET yb_enable_expression_pushdown = false; /*+ BitmapScan(pg_authid) */ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF) SELECT spcname FROM pg_tablespace WHERE spcowner NOT IN ( SELECT oid FROM pg_roles WHERE rolname = 'postgres' OR rolname LIKE 'pg_%' OR rolname LIKE 'yb_%'); - QUERY PLAN ------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Seq Scan on pg_tablespace (actual rows=0 loops=1) Filter: (NOT (hashed SubPlan 1)) Rows Removed by Filter: 2 SubPlan 1 - -> YB Bitmap Table Scan on pg_authid (actual rows=12 loops=1) + -> YB Bitmap Table Scan on pg_authid (actual rows=16 loops=1) + Recheck Cond: ((rolname = 'postgres'::name) OR ((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) OR ((rolname >= 'yb'::text) AND (rolname < 'yc'::text))) + Rows Removed by Index Recheck: 2 Filter: ((rolname = 'postgres'::name) OR (rolname ~~ 'pg_%'::text) OR (rolname ~~ 'yb_%'::text)) - -> BitmapOr (actual rows=12 loops=1) + -> BitmapOr (actual rows=18 loops=1) -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=1 loops=1) Index Cond: (rolname = 'postgres'::name) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=8 loops=1) - Index Cond: ((rolname >= 'pg'::name) AND (rolname < 'ph'::name)) - -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=3 loops=1) - Index Cond: ((rolname >= 'yb'::name) AND (rolname < 'yc'::name)) -(13 rows) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=18 loops=1) + Index Cond: ((rolname >= 'pg'::text) AND (rolname < 'ph'::text)) + -> Bitmap Index Scan on pg_authid_rolname_index (actual rows=18 loops=1) + Index Cond: ((rolname >= 'yb'::text) AND (rolname < 'yc'::text)) +(15 rows) /*+ BitmapScan(pg_authid) */ SELECT spcname FROM pg_tablespace WHERE spcowner NOT IN ( SELECT oid FROM pg_roles WHERE rolname = 'postgres' OR rolname LIKE 'pg_%' OR rolname LIKE 'yb_%'); diff --git a/src/postgres/src/test/regress/sql/yb_bitmap_scans_system.sql b/src/postgres/src/test/regress/sql/yb_bitmap_scans_system.sql index 5e4d0f881c25..f66431dbefe2 100644 --- a/src/postgres/src/test/regress/sql/yb_bitmap_scans_system.sql +++ b/src/postgres/src/test/regress/sql/yb_bitmap_scans_system.sql @@ -6,9 +6,9 @@ SET yb_enable_bitmapscan = true; SET enable_bitmapscan = true; /*+ BitmapScan(pg_authid) */ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF) -SELECT * FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; +SELECT rolname FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; /*+ BitmapScan(pg_authid) */ -SELECT * FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; +SELECT rolname FROM pg_authid WHERE rolname LIKE 'pg_%' OR rolname LIKE 'yb_%' ORDER BY rolname; /*+ BitmapScan(pg_authid) */ EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF) SELECT spcname FROM pg_tablespace WHERE spcowner NOT IN ( SELECT oid FROM pg_roles WHERE rolname = 'postgres' OR rolname LIKE 'pg_%' OR rolname LIKE 'yb_%');