@@ -142,6 +142,133 @@ SELECT b.*
142142 4500 | 2080851358
143143(1 row)
144144
145+ --
146+ -- Add coverage of RowCompare quals whose row omits a column ("proargtypes")
147+ -- that's after the first column, but before the final column. The scan's
148+ -- initial positioning strategy must become >= here (it's not the > strategy,
149+ -- since the absence of "proargtypes" makes that tighter constraint unsafe).
150+ --
151+ explain (costs off)
152+ SELECT proname, proargtypes, pronamespace
153+ FROM pg_proc
154+ WHERE (proname, pronamespace) > ('abs', 0)
155+ ORDER BY proname, proargtypes, pronamespace LIMIT 1;
156+ QUERY PLAN
157+ -------------------------------------------------------------------------------
158+ Limit
159+ -> Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc
160+ Index Cond: (ROW(proname, pronamespace) > ROW('abs'::name, '0'::oid))
161+ (3 rows)
162+
163+ SELECT proname, proargtypes, pronamespace
164+ FROM pg_proc
165+ WHERE (proname, pronamespace) > ('abs', 0)
166+ ORDER BY proname, proargtypes, pronamespace LIMIT 1;
167+ proname | proargtypes | pronamespace
168+ ---------+-------------+--------------
169+ abs | 20 | 11
170+ (1 row)
171+
172+ --
173+ -- Similar to the previous test case, but this time it's a backwards scan
174+ -- using a < RowCompare. Must use the <= strategy (and not the < strategy).
175+ --
176+ explain (costs off)
177+ SELECT proname, proargtypes, pronamespace
178+ FROM pg_proc
179+ WHERE (proname, pronamespace) < ('abs', 1_000_000)
180+ ORDER BY proname DESC, proargtypes DESC, pronamespace DESC LIMIT 1;
181+ QUERY PLAN
182+ -------------------------------------------------------------------------------------
183+ Limit
184+ -> Index Only Scan Backward using pg_proc_proname_args_nsp_index on pg_proc
185+ Index Cond: (ROW(proname, pronamespace) < ROW('abs'::name, '1000000'::oid))
186+ (3 rows)
187+
188+ SELECT proname, proargtypes, pronamespace
189+ FROM pg_proc
190+ WHERE (proname, pronamespace) < ('abs', 1_000_000)
191+ ORDER BY proname DESC, proargtypes DESC, pronamespace DESC LIMIT 1;
192+ proname | proargtypes | pronamespace
193+ ---------+-------------+--------------
194+ abs | 1700 | 11
195+ (1 row)
196+
197+ --
198+ -- Add coverage for RowCompare quals whose rhs row has a NULL that ends scan
199+ --
200+ explain (costs off)
201+ SELECT proname, proargtypes, pronamespace
202+ FROM pg_proc
203+ WHERE proname = 'abs' AND (proname, proargtypes) < ('abs', NULL)
204+ ORDER BY proname, proargtypes, pronamespace;
205+ QUERY PLAN
206+ -------------------------------------------------------------------------------------------------------------
207+ Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc
208+ Index Cond: ((ROW(proname, proargtypes) < ROW('abs'::name, NULL::oidvector)) AND (proname = 'abs'::name))
209+ (2 rows)
210+
211+ SELECT proname, proargtypes, pronamespace
212+ FROM pg_proc
213+ WHERE proname = 'abs' AND (proname, proargtypes) < ('abs', NULL)
214+ ORDER BY proname, proargtypes, pronamespace;
215+ proname | proargtypes | pronamespace
216+ ---------+-------------+--------------
217+ (0 rows)
218+
219+ --
220+ -- Add coverage for backwards scan RowCompare quals whose rhs row has a NULL
221+ -- that ends scan
222+ --
223+ explain (costs off)
224+ SELECT proname, proargtypes, pronamespace
225+ FROM pg_proc
226+ WHERE proname = 'abs' AND (proname, proargtypes) > ('abs', NULL)
227+ ORDER BY proname DESC, proargtypes DESC, pronamespace DESC;
228+ QUERY PLAN
229+ -------------------------------------------------------------------------------------------------------------
230+ Index Only Scan Backward using pg_proc_proname_args_nsp_index on pg_proc
231+ Index Cond: ((ROW(proname, proargtypes) > ROW('abs'::name, NULL::oidvector)) AND (proname = 'abs'::name))
232+ (2 rows)
233+
234+ SELECT proname, proargtypes, pronamespace
235+ FROM pg_proc
236+ WHERE proname = 'abs' AND (proname, proargtypes) > ('abs', NULL)
237+ ORDER BY proname DESC, proargtypes DESC, pronamespace DESC;
238+ proname | proargtypes | pronamespace
239+ ---------+-------------+--------------
240+ (0 rows)
241+
242+ --
243+ -- Add coverage for recheck of > key following array advancement on previous
244+ -- (left sibling) page that used a high key whose attribute value corresponding
245+ -- to the > key was -inf (due to being truncated when the high key was created).
246+ --
247+ -- XXX This relies on the assumption that tenk1_thous_tenthous has a truncated
248+ -- high key "(183, -inf)" on the first page that we'll scan. The test will only
249+ -- provide useful coverage when the default 8K BLCKSZ is in use.
250+ --
251+ explain (costs off)
252+ SELECT thousand, tenthous
253+ FROM tenk1
254+ WHERE thousand IN (182, 183) AND tenthous > 7550;
255+ QUERY PLAN
256+ ---------------------------------------------------------------------------------
257+ Index Only Scan using tenk1_thous_tenthous on tenk1
258+ Index Cond: ((thousand = ANY ('{182,183}'::integer[])) AND (tenthous > 7550))
259+ (2 rows)
260+
261+ SELECT thousand, tenthous
262+ FROM tenk1
263+ WHERE thousand IN (182, 183) AND tenthous > 7550;
264+ thousand | tenthous
265+ ----------+----------
266+ 182 | 8182
267+ 182 | 9182
268+ 183 | 8183
269+ 183 | 9183
270+ (4 rows)
271+
145272--
146273-- Add coverage for optimization of backwards scan index descents
147274--
0 commit comments