From bf5ed50f54f041782049b93abe9fa4bc43a4867d Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Tue, 13 Oct 2015 16:56:29 +0300 Subject: [PATCH] add althesame flag --- README.gevel | 15 +-- expected/gevel.out.9.6 | 228 ++++++++++++++++++++--------------------- gevel.c | 54 +++++----- sql/gevel.sql | 4 +- 4 files changed, 153 insertions(+), 148 deletions(-) diff --git a/README.gevel b/README.gevel index 2292c7a..b09529e 100644 --- a/README.gevel +++ b/README.gevel @@ -157,7 +157,8 @@ regression=# select gist_tree('pix'); # SELECT * FROM spgist_print('spgist_idx') as t ( - tid tid, + tid tid, + allthesame bool, node_n int, level int, tid_pointer tid, @@ -165,12 +166,12 @@ regression=# select gist_tree('pix'); node_label int, leaf_value point ) where level = 1; - tid | node_n | level | tid_pointer | prefix | node_label | leaf_value --------+--------+-------+-------------+-------------------------------------+------------+------------ - (1,1) | 0 | 1 | (5,4) | (24530.2070484581,23595.7092511013) | | - (1,1) | 1 | 1 | (5,3) | (24530.2070484581,23595.7092511013) | | - (1,1) | 2 | 1 | (5,2) | (24530.2070484581,23595.7092511013) | | - (1,1) | 3 | 1 | (5,1) | (24530.2070484581,23595.7092511013) | | + tid | allthesame | node_n | level | tid_pointer | prefix | node_label | leaf_value +-------+------------+--------+-------+-------------+-------------------------------------+------------+------------ + (1,1) | f | 0 | 1 | (5,4) | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 1 | 1 | (5,3) | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 2 | 1 | (5,2) | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 3 | 1 | (5,1) | (24530.2070484581,23595.7092511013) | | * gin_stat(INDEXNAME) prints estimated counts for each indexed values Note: since 8.4 gin_stat function has gin_stat(INDEXNAME, COLNUMBER) diff --git a/expected/gevel.out.9.6 b/expected/gevel.out.9.6 index 42a5e54..63f134d 100644 --- a/expected/gevel.out.9.6 +++ b/expected/gevel.out.9.6 @@ -28,33 +28,33 @@ SELECT gist_tree('gist_idx'); ----------------------------------------------------------------------------------------------- 0(l:0) blk: 0 numTuple: 28 free: 6940b(14.95%) rightlink:4294967295 (InvalidBlockNumber) + 1(l:1) blk: 2 numTuple: 278 free: 2588b(68.28%) rightlink:4294967295 (InvalidBlockNumber)+ - 2(l:1) blk: 18 numTuple: 123 free: 2736b(66.47%) rightlink:3 (OK) + - 3(l:1) blk: 8 numTuple: 128 free: 2516b(69.17%) rightlink:21 (OK) + + 2(l:1) blk: 19 numTuple: 123 free: 2736b(66.47%) rightlink:3 (OK) + + 3(l:1) blk: 8 numTuple: 128 free: 2516b(69.17%) rightlink:22 (OK) + 4(l:1) blk: 4 numTuple: 92 free: 4100b(49.75%) rightlink:23 (OK) + - 5(l:1) blk: 19 numTuple: 122 free: 2780b(65.93%) rightlink:7 (OK) + - 6(l:1) blk: 15 numTuple: 135 free: 2208b(72.94%) rightlink:11 (OK) + - 7(l:1) blk: 23 numTuple: 126 free: 2604b(68.09%) rightlink:8 (OK) + - 8(l:1) blk: 10 numTuple: 156 free: 1284b(84.26%) rightlink:18 (OK) + - 9(l:1) blk: 13 numTuple: 130 free: 2428b(70.25%) rightlink:19 (OK) + - 10(l:1) blk: 9 numTuple: 124 free: 2692b(67.01%) rightlink:24 (OK) + - 11(l:1) blk: 12 numTuple: 70 free: 5068b(37.89%) rightlink:25 (OK) + - 12(l:1) blk: 21 numTuple: 112 free: 3220b(60.54%) rightlink:10 (OK) + + 5(l:1) blk: 20 numTuple: 122 free: 2780b(65.93%) rightlink:7 (OK) + + 6(l:1) blk: 15 numTuple: 127 free: 2560b(68.63%) rightlink:11 (OK) + + 7(l:1) blk: 18 numTuple: 138 free: 2076b(74.56%) rightlink:9 (OK) + + 8(l:1) blk: 23 numTuple: 126 free: 2604b(68.09%) rightlink:8 (OK) + + 9(l:1) blk: 10 numTuple: 156 free: 1284b(84.26%) rightlink:19 (OK) + + 10(l:1) blk: 13 numTuple: 130 free: 2428b(70.25%) rightlink:20 (OK) + + 11(l:1) blk: 12 numTuple: 70 free: 5068b(37.89%) rightlink:24 (OK) + + 12(l:1) blk: 22 numTuple: 112 free: 3220b(60.54%) rightlink:10 (OK) + 13(l:1) blk: 16 numTuple: 89 free: 4232b(48.14%) rightlink:26 (OK) + 14(l:1) blk: 26 numTuple: 108 free: 3396b(58.38%) rightlink:5 (OK) + 15(l:1) blk: 7 numTuple: 99 free: 3792b(53.53%) rightlink:16 (OK) + - 16(l:1) blk: 6 numTuple: 85 free: 4408b(45.98%) rightlink:22 (OK) + + 16(l:1) blk: 6 numTuple: 120 free: 2868b(64.85%) rightlink:18 (OK) + 17(l:1) blk: 14 numTuple: 163 free: 976b(88.04%) rightlink:6 (OK) + 18(l:1) blk: 28 numTuple: 122 free: 2780b(65.93%) rightlink:12 (OK) + 19(l:1) blk: 3 numTuple: 57 free: 5640b(30.88%) rightlink:27 (OK) + - 20(l:1) blk: 24 numTuple: 80 free: 4628b(43.28%) rightlink:15 (OK) + - 21(l:1) blk: 17 numTuple: 89 free: 4232b(48.14%) rightlink:4 (OK) + - 22(l:1) blk: 20 numTuple: 166 free: 844b(89.66%) rightlink:13 (OK) + - 23(l:1) blk: 27 numTuple: 122 free: 2780b(65.93%) rightlink:14 (OK) + - 24(l:1) blk: 22 numTuple: 147 free: 1680b(79.41%) rightlink:9 (OK) + + 20(l:1) blk: 25 numTuple: 58 free: 5596b(31.42%) rightlink:15 (OK) + + 21(l:1) blk: 17 numTuple: 87 free: 4320b(47.06%) rightlink:4 (OK) + + 22(l:1) blk: 9 numTuple: 128 free: 2516b(69.17%) rightlink:25 (OK) + + 23(l:1) blk: 21 numTuple: 166 free: 844b(89.66%) rightlink:13 (OK) + + 24(l:1) blk: 27 numTuple: 124 free: 2692b(67.01%) rightlink:14 (OK) + 25(l:1) blk: 11 numTuple: 146 free: 1724b(78.87%) rightlink:2 (OK) + 26(l:1) blk: 5 numTuple: 61 free: 5464b(33.04%) rightlink:28 (OK) + - 27(l:1) blk: 1 numTuple: 92 free: 4100b(49.75%) rightlink:20 (OK) + - 28(l:1) blk: 25 numTuple: 156 free: 1284b(84.26%) rightlink:17 (OK) + + 27(l:1) blk: 1 numTuple: 92 free: 4100b(49.75%) rightlink:21 (OK) + + 28(l:1) blk: 24 numTuple: 156 free: 1284b(84.26%) rightlink:17 (OK) + (1 row) @@ -66,25 +66,25 @@ SELECT * FROM gist_print('gist_idx') as t(level int, valid bool, a box) where le 1 | t | (20400,41715),(9175,31485) 1 | t | (8924,39250),(3,31083) 1 | t | (20594,19151),(10869,10535) - 1 | t | (49999,42533),(43290,27088) + 1 | t | (49981,42533),(43290,28026) + 1 | t | (49999,27727),(40603,15778) 1 | t | (8993,50012),(64,39781) 1 | t | (32394,42395),(20513,31557) 1 | t | (20715,10161),(10407,51) - 1 | t | (42941,36244),(32606,27088) 1 | t | (32512,16364),(20947,11843) 1 | t | (20327,49975),(9216,42130) 1 | t | (13397,31188),(7334,19288) 1 | t | (20856,31294),(13642,19263) 1 | t | (6986,30859),(107,19466) - 1 | t | (39187,26879),(32770,15690) + 1 | t | (40397,28538),(32515,15759) 1 | t | (49985,15380),(42047,43) 1 | t | (32715,11509),(24675,6) 1 | t | (41916,5154),(32914,357) - 1 | t | (43056,42360),(32661,36457) - 1 | t | (32544,31262),(21146,25161) + 1 | t | (43056,42360),(32661,37729) + 1 | t | (32440,31262),(21146,25161) + 1 | t | (42941,37586),(32606,28547) 1 | t | (10104,18999),(15,7761) - 1 | t | (41835,15495),(32828,5360) - 1 | t | (49944,26858),(39348,15728) + 1 | t | (41835,15752),(32828,5360) 1 | t | (50027,50073),(32453,42694) 1 | t | (24423,11473),(20828,181) 1 | t | (10146,7495),(138,81) @@ -114,97 +114,97 @@ SELECT spgist_stat('spgist_idx'); innerRedirects: 0 (1 row) -SELECT * FROM spgist_print('kdspgist_idx') as t(tid tid, node_n int, level int, tid_pointer tid, prefix float8, node_label int, leaf_value point); - tid | node_n | level | tid_pointer | prefix | node_label | leaf_value -----------+--------+-------+-------------+---------+------------+------------------- - (1,1) | 0 | 1 | (5,1) | 23030 | | - (1,1) | 1 | 1 | (5,2) | 23030 | | - (5,2) | 0 | 2 | (5,6) | 21664 | | - (5,2) | 1 | 2 | (5,3) | 21664 | | - (5,3) | 0 | 3 | (5,5) | 37159.5 | | - (5,3) | 1 | 3 | (5,12) | 37159.5 | | - (5,12) | 0 | 4 | (5,13) | 36357.5 | | - (5,12) | 1 | 4 | (14,226) | 36357.5 | | - (14,226) | | 5 | | | | (43240,47256.5) - (5,13) | 0 | 5 | (3,112) | 43507 | | - (5,13) | 1 | 5 | (5,25) | 43507 | | - (5,25) | 0 | 6 | (22,116) | 28862 | | - (5,25) | 1 | 6 | (22,115) | 28862 | | - (22,115) | | 7 | | | | (30902,44532) - (22,116) | | 7 | | | | (23048,47416) - (3,112) | | 6 | | | | (35218.5,42124) - (5,5) | 0 | 4 | (5,11) | 33416 | | - (5,5) | 1 | 4 | (5,22) | 33416 | | - (5,22) | 0 | 5 | (20,225) | 30991 | | - (5,22) | 1 | 5 | (5,23) | 30991 | | - (5,23) | 0 | 6 | (9,112) | 41820 | | - (5,23) | 1 | 6 | (9,114) | 41820 | | - (9,114) | | 7 | | | | (44732,32182) - (9,112) | | 7 | | | | (35580,33526.5) - (20,225) | | 6 | | | | (47724.5,27185.5) - (5,11) | 0 | 5 | (13,101) | 29986.5 | | - (5,11) | 1 | 5 | (13,100) | 29986.5 | | - (13,100) | | 6 | | | | (24069,30850.5) - (13,101) | | 6 | | | | (29539,25566) - (5,6) | 0 | 3 | (5,7) | 36774 | | - (5,6) | 1 | 3 | (5,19) | 36774 | | - (5,19) | 0 | 4 | (5,20) | 10075.5 | | - (5,19) | 1 | 4 | (18,225) | 10075.5 | | - (18,225) | | 5 | | | | (20920.5,49105.5) - (5,20) | 0 | 5 | (10,110) | 44171.5 | | - (5,20) | 1 | 5 | (10,113) | 44171.5 | | - (10,113) | | 6 | | | | (93,46797) - (10,110) | | 6 | | | | (28.5,38640.5) - (5,7) | 0 | 4 | (7,113) | 9517 | | - (5,7) | 1 | 4 | (5,21) | 9517 | | - (5,21) | 0 | 5 | (19,115) | 28907.5 | | - (5,21) | 1 | 5 | (19,112) | 28907.5 | | - (19,112) | | 6 | | | | (11916.5,31668) - (19,115) | | 6 | | | | (20622.5,27462.5) - (7,113) | | 5 | | | | (9296,35157) - (5,1) | 0 | 2 | (5,8) | 26938 | | - (5,1) | 1 | 2 | (5,4) | 26938 | | - (5,4) | 0 | 3 | (5,10) | 9532 | | - (5,4) | 1 | 3 | (5,14) | 9532 | | - (5,14) | 0 | 4 | (5,15) | 38603 | | - (5,14) | 1 | 4 | (15,222) | 38603 | | - (15,222) | | 5 | | | | (41926.5,17934.5) - (5,15) | 0 | 5 | (8,113) | 16345 | | - (5,15) | 1 | 5 | (8,112) | 16345 | | - (8,112) | | 6 | | | | (32425,20702.5) - (8,113) | | 6 | | | | (29134,15559.5) - (5,10) | 0 | 4 | (12,94) | 38800.5 | | - (5,10) | 1 | 4 | (5,24) | 38800.5 | | - (5,24) | 0 | 5 | (21,108) | 4752 | | - (5,24) | 1 | 5 | (21,107) | 4752 | | - (21,107) | | 6 | | | | (49822.5,7097.5) - (21,108) | | 6 | | | | (40315.5,1689.5) - (12,94) | | 5 | | | | (30295.5,5090) - (5,8) | 0 | 3 | (5,17) | 11733.5 | | - (5,8) | 1 | 3 | (5,9) | 11733.5 | | - (5,9) | 0 | 4 | (6,114) | 11993 | | - (5,9) | 1 | 4 | (5,16) | 11993 | | - (5,16) | 0 | 5 | (16,123) | 17591 | | - (5,16) | 1 | 5 | (16,127) | 17591 | | - (16,127) | | 6 | | | | (18352.5,19366) - (16,123) | | 6 | | | | (24795,14921) - (6,114) | | 5 | | | | (6706,16676) - (5,17) | 0 | 4 | (5,18) | 13329.5 | | - (5,17) | 1 | 4 | (17,226) | 13329.5 | | - (17,226) | | 5 | | | | (23690,10214.5) - (5,18) | 0 | 5 | (11,113) | 6375 | | - (5,18) | 1 | 5 | (11,109) | 6375 | | - (11,109) | | 6 | | | | (5501.5,9916) - (11,113) | | 6 | | | | (1072.5,4752) +SELECT * FROM spgist_print('kdspgist_idx') as t(tid tid, allthesame bool, node_n int, level int, tid_pointer tid, prefix float8, node_label int, leaf_value point); + tid | allthesame | node_n | level | tid_pointer | prefix | node_label | leaf_value +----------+------------+--------+-------+-------------+---------+------------+------------------- + (1,1) | f | 0 | 1 | (5,1) | 23030 | | + (1,1) | f | 1 | 1 | (5,2) | 23030 | | + (5,2) | f | 0 | 2 | (5,6) | 21664 | | + (5,2) | f | 1 | 2 | (5,3) | 21664 | | + (5,3) | f | 0 | 3 | (5,5) | 37159.5 | | + (5,3) | f | 1 | 3 | (5,12) | 37159.5 | | + (5,12) | f | 0 | 4 | (5,13) | 36357.5 | | + (5,12) | f | 1 | 4 | (14,226) | 36357.5 | | + (14,226) | | | 5 | | | | (43240,47256.5) + (5,13) | f | 0 | 5 | | 43507 | | + (5,13) | f | 1 | 5 | | 43507 | | + (5,25) | f | 0 | 6 | | 28862 | | + (5,25) | f | 1 | 6 | | 28862 | | + (22,115) | | | 7 | | | | (30902,44532) + (22,116) | | | 7 | | | | (23048,47416) + (3,112) | | | 6 | | | | (35218.5,42124) + (5,5) | f | 0 | 4 | | 33416 | | + (5,5) | f | 1 | 4 | | 33416 | | + (5,22) | f | 0 | 5 | | 30991 | | + (5,22) | f | 1 | 5 | | 30991 | | + (5,23) | f | 0 | 6 | | 41820 | | + (5,23) | f | 1 | 6 | | 41820 | | + (9,114) | | | 7 | | | | (44732,32182) + (9,112) | | | 7 | | | | (35580,33526.5) + (20,225) | | | 6 | | | | (47724.5,27185.5) + (5,11) | f | 0 | 5 | | 29986.5 | | + (5,11) | f | 1 | 5 | | 29986.5 | | + (13,100) | | | 6 | | | | (24069,30850.5) + (13,101) | | | 6 | | | | (29539,25566) + (5,6) | f | 0 | 3 | | 36774 | | + (5,6) | f | 1 | 3 | | 36774 | | + (5,19) | f | 0 | 4 | | 10075.5 | | + (5,19) | f | 1 | 4 | | 10075.5 | | + (18,225) | | | 5 | | | | (20920.5,49105.5) + (5,20) | f | 0 | 5 | | 44171.5 | | + (5,20) | f | 1 | 5 | | 44171.5 | | + (10,113) | | | 6 | | | | (93,46797) + (10,110) | | | 6 | | | | (28.5,38640.5) + (5,7) | f | 0 | 4 | | 9517 | | + (5,7) | f | 1 | 4 | | 9517 | | + (5,21) | f | 0 | 5 | | 28907.5 | | + (5,21) | f | 1 | 5 | | 28907.5 | | + (19,112) | | | 6 | | | | (11916.5,31668) + (19,115) | | | 6 | | | | (20622.5,27462.5) + (7,113) | | | 5 | | | | (9296,35157) + (5,1) | f | 0 | 2 | | 26938 | | + (5,1) | f | 1 | 2 | | 26938 | | + (5,4) | f | 0 | 3 | | 9532 | | + (5,4) | f | 1 | 3 | | 9532 | | + (5,14) | f | 0 | 4 | | 38603 | | + (5,14) | f | 1 | 4 | | 38603 | | + (15,222) | | | 5 | | | | (41926.5,17934.5) + (5,15) | f | 0 | 5 | | 16345 | | + (5,15) | f | 1 | 5 | | 16345 | | + (8,112) | | | 6 | | | | (32425,20702.5) + (8,113) | | | 6 | | | | (29134,15559.5) + (5,10) | f | 0 | 4 | | 38800.5 | | + (5,10) | f | 1 | 4 | | 38800.5 | | + (5,24) | f | 0 | 5 | | 4752 | | + (5,24) | f | 1 | 5 | | 4752 | | + (21,107) | | | 6 | | | | (49822.5,7097.5) + (21,108) | | | 6 | | | | (40315.5,1689.5) + (12,94) | | | 5 | | | | (30295.5,5090) + (5,8) | f | 0 | 3 | | 11733.5 | | + (5,8) | f | 1 | 3 | | 11733.5 | | + (5,9) | f | 0 | 4 | | 11993 | | + (5,9) | f | 1 | 4 | | 11993 | | + (5,16) | f | 0 | 5 | | 17591 | | + (5,16) | f | 1 | 5 | | 17591 | | + (16,127) | | | 6 | | | | (18352.5,19366) + (16,123) | | | 6 | | | | (24795,14921) + (6,114) | | | 5 | | | | (6706,16676) + (5,17) | f | 0 | 4 | | 13329.5 | | + (5,17) | f | 1 | 4 | | 13329.5 | | + (17,226) | | | 5 | | | | (23690,10214.5) + (5,18) | f | 0 | 5 | | 6375 | | + (5,18) | f | 1 | 5 | | 6375 | | + (11,109) | | | 6 | | | | (5501.5,9916) + (11,113) | | | 6 | | | | (1072.5,4752) (79 rows) -SELECT * FROM spgist_print('spgist_idx') as t(tid tid, node_n int, level int, tid_pointer tid, prefix point, node_label int, leaf_value point) WHERE level = 1; - tid | node_n | level | tid_pointer | prefix | node_label | leaf_value --------+--------+-------+-------------+-------------------------------------+------------+------------ - (1,1) | 0 | 1 | (5,4) | (24530.2070484581,23595.7092511013) | | - (1,1) | 1 | 1 | (5,3) | (24530.2070484581,23595.7092511013) | | - (1,1) | 2 | 1 | (5,2) | (24530.2070484581,23595.7092511013) | | - (1,1) | 3 | 1 | (5,1) | (24530.2070484581,23595.7092511013) | | +SELECT * FROM spgist_print('spgist_idx') as t(tid tid, allthesame bool, node_n int, level int, tid_pointer tid, prefix point, node_label int, leaf_value point) WHERE level = 1; + tid | allthesame | node_n | level | tid_pointer | prefix | node_label | leaf_value +-------+------------+--------+-------+-------------+-------------------------------------+------------+------------ + (1,1) | f | 0 | 1 | | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 1 | 1 | | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 2 | 1 | | (24530.2070484581,23595.7092511013) | | + (1,1) | f | 3 | 1 | | (24530.2070484581,23595.7092511013) | | (4 rows) --GIN diff --git a/gevel.c b/gevel.c index 6a62b85..b464de0 100644 --- a/gevel.c +++ b/gevel.c @@ -1042,8 +1042,8 @@ typedef struct SPGistPrintStackElem { typedef struct SPGistPrint { SpGistState state; Relation index; - Datum dvalues[7 /* see CreateTemplateTupleDesc call */]; - char nulls[7 /* see CreateTemplateTupleDesc call */]; + Datum dvalues[8 /* see CreateTemplateTupleDesc call */]; + char nulls[8 /* see CreateTemplateTupleDesc call */]; List *stack; } SPGistPrint; @@ -1108,16 +1108,17 @@ spgist_print(PG_FUNCTION_ARGS) prst->index = index; initSpGistState(&prst->state, index); - tupdesc = CreateTemplateTupleDesc(3 /* types */ + 1 /* level */ + 1 /* nlabel */ + 2 /* tids */, false); + tupdesc = CreateTemplateTupleDesc(3 /* types */ + 1 /* level */ + 1 /* nlabel */ + 2 /* tids */ + 1, false); TupleDescInitEntry(tupdesc, 1, "tid", TIDOID, -1, 0); - TupleDescInitEntry(tupdesc, 2, "node", INT4OID, -1, 0); - TupleDescInitEntry(tupdesc, 3, "level", INT4OID, -1, 0); - TupleDescInitEntry(tupdesc, 4, "tid_pointer", TIDOID, -1, 0); - TupleDescInitEntry(tupdesc, 5, "prefix", + TupleDescInitEntry(tupdesc, 2, "allthesame", BOOLOID, -1, 0); + TupleDescInitEntry(tupdesc, 3, "node", INT4OID, -1, 0); + TupleDescInitEntry(tupdesc, 4, "level", INT4OID, -1, 0); + TupleDescInitEntry(tupdesc, 5, "tid_pointer", TIDOID, -1, 0); + TupleDescInitEntry(tupdesc, 6, "prefix", (prst->state.attPrefixType.type == VOIDOID) ? INT4OID : prst->state.attPrefixType.type, -1, 0); - TupleDescInitEntry(tupdesc, 6, "label", + TupleDescInitEntry(tupdesc, 7, "label", (prst->state.attLabelType.type == VOIDOID) ? INT4OID : prst->state.attLabelType.type, -1, 0); - TupleDescInitEntry(tupdesc, 7, "leaf", + TupleDescInitEntry(tupdesc, 8, "leaf", (prst->state.attType.type == VOIDOID) ? INT4OID : prst->state.attType.type, -1, 0); funcctx->slot = TupleDescGetSlot(tupdesc); @@ -1186,14 +1187,15 @@ next: prst->dvalues[0] = PointerGetDatum(tid); prst->nulls[0] = ISNOTNULL; prst->nulls[1] = ISNULL; - prst->dvalues[2] = s->level; - prst->nulls[2] = ISNOTNULL; - prst->nulls[3] = ISNULL; + prst->nulls[2] = ISNULL; + prst->dvalues[3] = s->level; + prst->nulls[3] = ISNOTNULL; prst->nulls[4] = ISNULL; prst->nulls[5] = ISNULL; - prst->dvalues[6] = datumCopy(SGLTDATUM(leafTuple, &prst->state), + prst->nulls[6] = ISNULL; + prst->dvalues[7] = datumCopy(SGLTDATUM(leafTuple, &prst->state), prst->state.attType.attbyval, prst->state.attType.attlen); - prst->nulls[6] = ISNOTNULL; + prst->nulls[7] = ISNOTNULL; } else { SpGistInnerTuple innerTuple = (SpGistInnerTuple)dtuple; int i; @@ -1216,27 +1218,29 @@ next: *tid = s->iptr; prst->dvalues[0] = PointerGetDatum(tid); prst->nulls[0] = ISNOTNULL; - prst->dvalues[1] = Int32GetDatum(s->nlabel); + prst->dvalues[1] = innerTuple->allTheSame; prst->nulls[1] = ISNOTNULL; - prst->dvalues[2] = s->level; + prst->dvalues[2] = Int32GetDatum(s->nlabel); prst->nulls[2] = ISNOTNULL; + prst->dvalues[3] = s->level; + prst->nulls[3] = ISNOTNULL; tid = palloc(sizeof(ItemPointerData)); *tid = node->t_tid; - prst->dvalues[3] = PointerGetDatum(tid); - prst->nulls[3] = ISNOTNULL; + prst->dvalues[4] = PointerGetDatum(tid); + prst->nulls[5] = ISNOTNULL; if (innerTuple->prefixSize > 0) { - prst->dvalues[4] = datumCopy(SGITDATUM(innerTuple, &prst->state), + prst->dvalues[5] = datumCopy(SGITDATUM(innerTuple, &prst->state), prst->state.attPrefixType.attbyval, prst->state.attPrefixType.attlen); - prst->nulls[4] = ISNOTNULL; + prst->nulls[5] = ISNOTNULL; } else - prst->nulls[4] = ISNULL; + prst->nulls[5] = ISNULL; if (!IndexTupleHasNulls(node)) { - prst->dvalues[5] = datumCopy(SGNTDATUM(node, &prst->state), + prst->dvalues[6] = datumCopy(SGNTDATUM(node, &prst->state), prst->state.attLabelType.attbyval, prst->state.attLabelType.attlen); - prst->nulls[5] = ISNOTNULL; + prst->nulls[6] = ISNOTNULL; } else - prst->nulls[5] = ISNULL; - prst->nulls[6] = ISNULL; + prst->nulls[6] = ISNULL; + prst->nulls[7] = ISNULL; pushSPGistPrint(funcctx, prst, &node->t_tid, s->level + 1); s->nlabel = i + 1; diff --git a/sql/gevel.sql b/sql/gevel.sql index 976e9aa..2a5d653 100644 --- a/sql/gevel.sql +++ b/sql/gevel.sql @@ -21,8 +21,8 @@ SELECT * FROM gist_print('gist_idx') as t(level int, valid bool, a box) where le --SPGiST SELECT spgist_stat('spgist_idx'); -SELECT * FROM spgist_print('kdspgist_idx') as t(tid tid, node_n int, level int, tid_pointer tid, prefix float8, node_label int, leaf_value point); -SELECT * FROM spgist_print('spgist_idx') as t(tid tid, node_n int, level int, tid_pointer tid, prefix point, node_label int, leaf_value point) WHERE level = 1; +SELECT * FROM spgist_print('kdspgist_idx') as t(tid tid, allthesame bool, node_n int, level int, tid_pointer tid, prefix float8, node_label int, leaf_value point); +SELECT * FROM spgist_print('spgist_idx') as t(tid tid, allthesame bool, node_n int, level int, tid_pointer tid, prefix point, node_label int, leaf_value point) WHERE level = 1; --GIN CREATE TABLE test__int( a int[] ); -- 2.46.1