Skip to content

Commit fd282ce

Browse files
author
Arseny Kositsyn
committed
[PGPRO-12159] Code review.
Refactoring has been performed. The code is divided into more logical blocks using added functions and macros with clear names. Tags: rum
1 parent 9665cf6 commit fd282ce

File tree

6 files changed

+748
-995
lines changed

6 files changed

+748
-995
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ include $(top_builddir)/src/Makefile.global
4545
include $(top_srcdir)/contrib/contrib-global.mk
4646
endif
4747

48-
$(EXTENSION)--$(EXTVERSION).sql: rum_init.sql
49-
cat $^ > $@
50-
5148
# rum_debug_funcs tests only for enterprise
5249
ifneq ($(PGPRO_EDITION), enterprise)
5350
REGRESS := $(filter-out rum_debug_funcs, $(REGRESS))
5451
endif
5552

53+
$(EXTENSION)--$(EXTVERSION).sql: rum_init.sql
54+
cat $^ > $@
55+
5656
#
5757
# On versions 12 and 13 isolation tests cannot be run using pgxs.
5858
# Override installcheck target to avoid the error. This is just a

expected/rum_debug_funcs.out

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8013,7 +8013,7 @@ SELECT * FROM rum_leaf_data_page_items('test_with_addinfo_idx_true', 22);
80138013
(736 rows)
80148014

80158015
DROP TABLE test_debug_table;
8016-
-- Проверяем с позициями лексем
8016+
-- Check with the positions of the lexemes
80178017
CREATE TABLE test_debug_table_with_weight(t text, a tsvector, r text);
80188018
CREATE FUNCTION fill_test_debug_weight_trigger() RETURNS trigger AS $$
80198019
begin
@@ -8638,12 +8638,12 @@ SELECT * FROM rum_page_opaque_info('test_with_weight_idx', 21);
86388638
(1 row)
86398639

86408640
SELECT * FROM rum_internal_data_page_items('test_with_weight_idx', 21);
8641-
is_high_key | block_number | tuple_id | add_info_is_null | add_info
8642-
-------------+--------------+----------+------------------+-----------------------------------------------------
8641+
is_high_key | block_number | tuple_id | add_info_is_null | add_info
8642+
-------------+--------------+----------+------------------+------------------------------------------------
86438643
t | | (0,0) | t |
8644-
f | 23 | (39,43) | f | high key positions in posting tree is not supported
8645-
f | 22 | (74,9) | f | high key positions in posting tree is not supported
8646-
f | 24 | (98,9) | f | high key positions in posting tree is not supported
8644+
f | 23 | (39,43) | f | varlena types in posting tree is not supported
8645+
f | 22 | (74,9) | f | varlena types in posting tree is not supported
8646+
f | 24 | (98,9) | f | varlena types in posting tree is not supported
86478647
f | 25 | (0,0) | t |
86488648
(5 rows)
86498649

@@ -8654,9 +8654,9 @@ SELECT * FROM rum_page_opaque_info('test_with_weight_idx', 22);
86548654
(1 row)
86558655

86568656
SELECT * FROM rum_leaf_data_page_items('test_with_weight_idx', 22);
8657-
is_high_key | tuple_id | add_info_is_null | add_info
8658-
-------------+----------+------------------+-----------------------------------------------------
8659-
t | (74,9) | f | high key positions in posting tree is not supported
8657+
is_high_key | tuple_id | add_info_is_null | add_info
8658+
-------------+----------+------------------+------------------------------------------------
8659+
t | (74,9) | f | varlena types in posting tree is not supported
86608660
f | (40,1) | f | 1A,9
86618661
f | (40,2) | f | 1A,9
86628662
f | (40,3) | f | 1A,9

expected/rum_debug_funcs_1.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7273,7 +7273,7 @@ SELECT * FROM rum_leaf_data_page_items('test_with_addinfo_idx_true', 22);
72737273
(763 rows)
72747274

72757275
DROP TABLE test_debug_table;
7276-
-- Проверяем с позициями лексем
7276+
-- Check with the positions of the lexemes
72777277
CREATE TABLE test_debug_table_with_weight(t text, a tsvector, r text);
72787278
CREATE FUNCTION fill_test_debug_weight_trigger() RETURNS trigger AS $$
72797279
begin

rum_init.sql

Lines changed: 91 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,51 +1752,101 @@ CREATE FUNCTION rum_page_opaque_info(
17521752
AS 'MODULE_PATHNAME', 'rum_page_opaque_info'
17531753
LANGUAGE C STRICT PARALLEL SAFE;
17541754

1755-
CREATE FUNCTION rum_leaf_data_page_items(
1756-
IN rel_name text,
1757-
IN blk_num int4,
1758-
OUT is_high_key bool,
1759-
OUT tuple_id tid,
1760-
OUT add_info_is_null bool,
1761-
OUT add_info varchar)
1755+
CREATE OR REPLACE FUNCTION
1756+
rum_page_items_info(rel_name text, blk_num int4, page_type int4)
17621757
RETURNS SETOF record
1763-
AS 'MODULE_PATHNAME', 'rum_leaf_data_page_items'
1764-
LANGUAGE C STRICT PARALLEL SAFE;
1758+
AS 'MODULE_PATHNAME', 'rum_page_items_info'
1759+
LANGUAGE C STRICT;
1760+
1761+
CREATE FUNCTION rum_leaf_data_page_items(
1762+
rel_name text,
1763+
blk_num int4
1764+
)
1765+
RETURNS TABLE(
1766+
is_high_key bool,
1767+
tuple_id tid,
1768+
add_info_is_null bool,
1769+
add_info varchar
1770+
)
1771+
AS $$
1772+
SELECT *
1773+
FROM rum_page_items_info(rel_name, blk_num, 0)
1774+
AS rum_page_items_info(
1775+
is_high_key bool,
1776+
tuple_id tid,
1777+
add_info_is_null bool,
1778+
add_info varchar
1779+
);
1780+
$$ LANGUAGE sql;
17651781

17661782
CREATE FUNCTION rum_internal_data_page_items(
1767-
IN rel_name text,
1768-
IN blk_num int4,
1769-
OUT is_high_key bool,
1770-
OUT block_number int4,
1771-
OUT tuple_id tid,
1772-
OUT add_info_is_null bool,
1773-
OUT add_info varchar)
1774-
RETURNS SETOF record
1775-
AS 'MODULE_PATHNAME', 'rum_internal_data_page_items'
1776-
LANGUAGE C STRICT PARALLEL SAFE;
1783+
rel_name text,
1784+
blk_num int4
1785+
)
1786+
RETURNS TABLE(
1787+
is_high_key bool,
1788+
block_number int4,
1789+
tuple_id tid,
1790+
add_info_is_null bool,
1791+
add_info varchar
1792+
)
1793+
AS $$
1794+
SELECT *
1795+
FROM rum_page_items_info(rel_name, blk_num, 1)
1796+
AS rum_page_items_info(
1797+
is_high_key bool,
1798+
block_number int4,
1799+
tuple_id tid,
1800+
add_info_is_null bool,
1801+
add_info varchar
1802+
);
1803+
$$ LANGUAGE sql;
17771804

17781805
CREATE FUNCTION rum_leaf_entry_page_items(
1779-
IN rel_name text,
1780-
IN blk_num int4,
1781-
OUT key varchar,
1782-
OUT attrnum int4,
1783-
OUT category varchar,
1784-
OUT tuple_id tid,
1785-
OUT add_info_is_null bool,
1786-
OUT add_info varchar,
1787-
OUT is_postring_tree bool,
1788-
OUT postring_tree_root int4)
1789-
RETURNS SETOF record
1790-
AS 'MODULE_PATHNAME', 'rum_leaf_entry_page_items'
1791-
LANGUAGE C STRICT PARALLEL SAFE;
1806+
rel_name text,
1807+
blk_num int4
1808+
)
1809+
RETURNS TABLE(
1810+
key varchar,
1811+
attrnum int4,
1812+
category varchar,
1813+
tuple_id tid,
1814+
add_info_is_null bool,
1815+
add_info varchar,
1816+
is_postring_tree bool,
1817+
postring_tree_root int4
1818+
)
1819+
AS $$
1820+
SELECT *
1821+
FROM rum_page_items_info(rel_name, blk_num, 2)
1822+
AS rum_page_items_info(
1823+
key varchar,
1824+
attrnum int4,
1825+
category varchar,
1826+
tuple_id tid,
1827+
add_info_is_null bool,
1828+
add_info varchar,
1829+
is_postring_tree bool,
1830+
postring_tree_root int4
1831+
);
1832+
$$ LANGUAGE sql;
17921833

17931834
CREATE FUNCTION rum_internal_entry_page_items(
1794-
IN rel_name text,
1795-
IN blk_num int4,
1796-
OUT key varchar,
1797-
OUT attrnum int4,
1798-
OUT category varchar,
1799-
OUT down_link int4)
1800-
RETURNS SETOF record
1801-
AS 'MODULE_PATHNAME', 'rum_internal_entry_page_items'
1802-
LANGUAGE C STRICT PARALLEL SAFE;
1835+
rel_name text,
1836+
blk_num int4
1837+
)
1838+
RETURNS TABLE(
1839+
key varchar,
1840+
attrnum int4,
1841+
category varchar,
1842+
down_link int4)
1843+
AS $$
1844+
SELECT *
1845+
FROM rum_page_items_info(rel_name, blk_num, 3)
1846+
AS rum_page_items_info(
1847+
key varchar,
1848+
attrnum int4,
1849+
category varchar,
1850+
down_link int4
1851+
);
1852+
$$ LANGUAGE sql;

sql/rum_debug_funcs.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ SELECT * FROM rum_leaf_data_page_items('test_with_addinfo_idx_true', 22);
8585

8686
DROP TABLE test_debug_table;
8787

88-
-- Проверяем с позициями лексем
88+
-- Check with the positions of the lexemes
8989
CREATE TABLE test_debug_table_with_weight(t text, a tsvector, r text);
9090

9191
CREATE FUNCTION fill_test_debug_weight_trigger() RETURNS trigger AS $$

0 commit comments

Comments
 (0)