PostgreSQL Source Code: src/test/modules/test_bitmapset/test_bitmapset.c Source File

PostgreSQL Source Code git master
test_bitmapset.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * test_bitmapset.c
4 * Test the Bitmapset data structure.
5 *
6 * This module tests the Bitmapset implementation in PostgreSQL, covering
7 * all public API functions.
8 *
9 * Copyright (c) 2025, PostgreSQL Global Development Group
10 *
11 * IDENTIFICATION
12 * src/test/modules/test_bitmapset/test_bitmapset.c
13 *
14 *-------------------------------------------------------------------------
15 */
16
17#include "postgres.h"
18
19#include <stddef.h>
20#include "catalog/pg_type.h"
21#include "common/pg_prng.h"
22#include "utils/array.h"
23#include "fmgr.h"
24#include "nodes/bitmapset.h"
25#include "nodes/nodes.h"
26#include "nodes/pg_list.h"
27#include "utils/builtins.h"
28#include "utils/timestamp.h"
29
30 PG_MODULE_MAGIC;
31
32/* Bitmapset API functions in order of appearance in bitmapset.c */
33 PG_FUNCTION_INFO_V1(test_bms_make_singleton);
34 PG_FUNCTION_INFO_V1(test_bms_add_member);
35 PG_FUNCTION_INFO_V1(test_bms_del_member);
36 PG_FUNCTION_INFO_V1(test_bms_is_member);
37 PG_FUNCTION_INFO_V1(test_bms_num_members);
38 PG_FUNCTION_INFO_V1(test_bms_copy);
39 PG_FUNCTION_INFO_V1(test_bms_equal);
40 PG_FUNCTION_INFO_V1(test_bms_compare);
41 PG_FUNCTION_INFO_V1(test_bms_is_subset);
42 PG_FUNCTION_INFO_V1(test_bms_subset_compare);
43 PG_FUNCTION_INFO_V1(test_bms_union);
44 PG_FUNCTION_INFO_V1(test_bms_intersect);
45 PG_FUNCTION_INFO_V1(test_bms_difference);
46 PG_FUNCTION_INFO_V1(test_bms_is_empty);
47 PG_FUNCTION_INFO_V1(test_bms_membership);
48 PG_FUNCTION_INFO_V1(test_bms_singleton_member);
49 PG_FUNCTION_INFO_V1(test_bms_get_singleton_member);
50 PG_FUNCTION_INFO_V1(test_bms_next_member);
51 PG_FUNCTION_INFO_V1(test_bms_prev_member);
52 PG_FUNCTION_INFO_V1(test_bms_hash_value);
53 PG_FUNCTION_INFO_V1(test_bms_overlap);
54 PG_FUNCTION_INFO_V1(test_bms_overlap_list);
55 PG_FUNCTION_INFO_V1(test_bms_nonempty_difference);
56 PG_FUNCTION_INFO_V1(test_bms_member_index);
57 PG_FUNCTION_INFO_V1(test_bms_add_range);
58 PG_FUNCTION_INFO_V1(test_bms_add_members);
59 PG_FUNCTION_INFO_V1(test_bms_int_members);
60 PG_FUNCTION_INFO_V1(test_bms_del_members);
61 PG_FUNCTION_INFO_V1(test_bms_replace_members);
62 PG_FUNCTION_INFO_V1(test_bms_join);
63 PG_FUNCTION_INFO_V1(test_bitmap_hash);
64 PG_FUNCTION_INFO_V1(test_bitmap_match);
65
66/* Test utility functions */
67 PG_FUNCTION_INFO_V1(test_random_operations);
68
69/* Convenient macros to test results */
70 #define EXPECT_TRUE(expr) \
71 do { \
72 if (!(expr)) \
73 elog(ERROR, \
74 "%s was unexpectedly false in file \"%s\" line %u", \
75 #expr, __FILE__, __LINE__); \
76 } while (0)
77
78 #define EXPECT_NOT_NULL(expr) \
79 do { \
80 if ((expr) == NULL) \
81 elog(ERROR, \
82 "%s was unexpectedly true in file \"%s\" line %u", \
83 #expr, __FILE__, __LINE__); \
84 } while (0)
85
86/* Encode/Decode to/from TEXT and Bitmapset */
87 #define BITMAPSET_TO_TEXT(bms) cstring_to_text(nodeToString(bms))
88 #define TEXT_TO_BITMAPSET(str) ((Bitmapset *) stringToNode(text_to_cstring(str)))
89
90/*
91 * Helper macro to fetch text parameters as Bitmapsets. SQL-NULL means empty
92 * set.
93 */
94 #define PG_ARG_GETBITMAPSET(n) \
95 (PG_ARGISNULL(n) ? NULL : TEXT_TO_BITMAPSET(PG_GETARG_TEXT_PP(n)))
96
97/*
98 * Helper macro to handle converting sets back to text, returning the
99 * resulting text representation of the set.
100 */
101 #define PG_RETURN_BITMAPSET_AS_TEXT(bms) \
102 PG_RETURN_TEXT_P(BITMAPSET_TO_TEXT(bms))
103
104/*
105 * Individual test functions for each bitmapset API function
106 *
107 * Primarily, we aim to keep these as close to simple wrapper functions as
108 * possible in order to publish the functions of bitmapset.c to the SQL layer
109 * with as little interference as possible. We opt to return SQL NULL in
110 * cases where the input given to the SQL function isn't valid to pass to the
111 * underlying bitmapset.c function. For example we cannot do much useful
112 * testing if someone calls test_bms_make_singleton(NULL) since
113 * bms_make_singleton() expects an integer argument.
114 *
115 * For function arguments which are to be converted to Bitmapsets, we accept
116 * SQL NULL as a valid argument to mean an empty set. Optionally callers may
117 * pass '(b)'.
118 *
119 * For the test functions which return a Bitmapset, these are converted back
120 * to text with result generated by nodeToString().
121 */
122
123Datum
124 test_bms_add_member(PG_FUNCTION_ARGS)
125{
126 Bitmapset *bms;
127 int member;
128
129 if (PG_ARGISNULL(1))
130 PG_RETURN_NULL(); /* invalid input */
131
132 bms = PG_ARG_GETBITMAPSET(0);
133 member = PG_GETARG_INT32(1);
134
135 bms = bms_add_member(bms, member);
136
137 PG_RETURN_BITMAPSET_AS_TEXT(bms);
138}
139
140Datum
141 test_bms_add_members(PG_FUNCTION_ARGS)
142{
143 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
144 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
145
146 /* left input is recycled */
147 bms1 = bms_add_members(bms1, bms2);
148
149 PG_RETURN_BITMAPSET_AS_TEXT(bms1);
150}
151
152Datum
153 test_bms_del_member(PG_FUNCTION_ARGS)
154{
155 Bitmapset *bms;
156 int32 member;
157
158 if (PG_ARGISNULL(1))
159 PG_RETURN_NULL(); /* invalid input */
160
161 bms = PG_ARG_GETBITMAPSET(0);
162 member = PG_GETARG_INT32(1);
163
164 bms = bms_del_member(bms, member);
165
166 PG_RETURN_BITMAPSET_AS_TEXT(bms);
167}
168
169Datum
170 test_bms_is_member(PG_FUNCTION_ARGS)
171{
172 Bitmapset *bms;
173 int32 member;
174 bool result;
175
176 if (PG_ARGISNULL(1))
177 PG_RETURN_NULL(); /* invalid input */
178
179 bms = PG_ARG_GETBITMAPSET(0);
180 member = PG_GETARG_INT32(1);
181
182 result = bms_is_member(member, bms);
183
184 PG_RETURN_BOOL(result);
185}
186
187Datum
188 test_bms_num_members(PG_FUNCTION_ARGS)
189{
190 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
191 int result;
192
193 result = bms_num_members(bms);
194
195 PG_RETURN_INT32(result);
196}
197
198Datum
199 test_bms_make_singleton(PG_FUNCTION_ARGS)
200{
201 Bitmapset *bms;
202 int32 member;
203
204 member = PG_GETARG_INT32(0);
205 bms = bms_make_singleton(member);
206
207 PG_RETURN_BITMAPSET_AS_TEXT(bms);
208}
209
210Datum
211 test_bms_copy(PG_FUNCTION_ARGS)
212{
213 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
214 Bitmapset *copy_bms;
215
216 copy_bms = bms_copy(bms);
217
218 PG_RETURN_BITMAPSET_AS_TEXT(copy_bms);
219}
220
221Datum
222 test_bms_equal(PG_FUNCTION_ARGS)
223{
224 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
225 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
226 bool result;
227
228 result = bms_equal(bms1, bms2);
229
230 PG_RETURN_BOOL(result);
231}
232
233Datum
234 test_bms_union(PG_FUNCTION_ARGS)
235{
236 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
237 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
238 Bitmapset *result_bms;
239
240 result_bms = bms_union(bms1, bms2);
241
242 PG_RETURN_BITMAPSET_AS_TEXT(result_bms);
243}
244
245Datum
246 test_bms_membership(PG_FUNCTION_ARGS)
247{
248 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
249 BMS_Membership result;
250
251 result = bms_membership(bms);
252
253 PG_RETURN_INT32((int32) result);
254}
255
256Datum
257 test_bms_next_member(PG_FUNCTION_ARGS)
258{
259 Bitmapset *bms;
260 int32 prevmember;
261 int result;
262
263 if (PG_ARGISNULL(1))
264 PG_RETURN_NULL(); /* invalid input */
265
266 bms = PG_ARG_GETBITMAPSET(0);
267 prevmember = PG_GETARG_INT32(1);
268
269 result = bms_next_member(bms, prevmember);
270
271 PG_RETURN_INT32(result);
272}
273
274Datum
275 test_bms_intersect(PG_FUNCTION_ARGS)
276{
277 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
278 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
279 Bitmapset *result_bms;
280
281 result_bms = bms_intersect(bms1, bms2);
282
283 PG_RETURN_BITMAPSET_AS_TEXT(result_bms);
284}
285
286Datum
287 test_bms_difference(PG_FUNCTION_ARGS)
288{
289 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
290 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
291 Bitmapset *result_bms;
292
293 result_bms = bms_difference(bms1, bms2);
294
295 PG_RETURN_BITMAPSET_AS_TEXT(result_bms);
296}
297
298Datum
299 test_bms_compare(PG_FUNCTION_ARGS)
300{
301 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
302 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
303 int result;
304
305 result = bms_compare(bms1, bms2);
306
307 PG_RETURN_INT32(result);
308}
309
310Datum
311 test_bms_is_empty(PG_FUNCTION_ARGS)
312{
313 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
314 bool result;
315
316 result = bms_is_empty(bms);
317
318 PG_RETURN_BOOL(result);
319}
320
321Datum
322 test_bms_is_subset(PG_FUNCTION_ARGS)
323{
324 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
325 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
326 bool result;
327
328 result = bms_is_subset(bms1, bms2);
329
330 PG_RETURN_BOOL(result);
331}
332
333Datum
334 test_bms_subset_compare(PG_FUNCTION_ARGS)
335{
336 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
337 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
338 BMS_Comparison result;
339
340 result = bms_subset_compare(bms1, bms2);
341
342 PG_RETURN_INT32((int32) result);
343}
344
345Datum
346 test_bms_singleton_member(PG_FUNCTION_ARGS)
347{
348 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
349 int result;
350
351 result = bms_singleton_member(bms);
352
353 PG_RETURN_INT32(result);
354}
355
356Datum
357 test_bms_get_singleton_member(PG_FUNCTION_ARGS)
358{
359 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
360 int member;
361
362 /*
363 * Keep this simple. Return -1 when we detect the set is not a singleton
364 * set, otherwise return the singleton member.
365 */
366 if (!bms_get_singleton_member(bms, &member))
367 member = -1;
368
369 PG_RETURN_INT32(member);
370}
371
372Datum
373 test_bms_prev_member(PG_FUNCTION_ARGS)
374{
375 Bitmapset *bms;
376 int32 prevmember;
377 int result;
378
379 if (PG_ARGISNULL(1))
380 PG_RETURN_NULL(); /* invalid input */
381
382 bms = PG_ARG_GETBITMAPSET(0);
383 prevmember = PG_GETARG_INT32(1);
384
385 result = bms_prev_member(bms, prevmember);
386
387 PG_RETURN_INT32(result);
388}
389
390Datum
391 test_bms_overlap(PG_FUNCTION_ARGS)
392{
393 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
394 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
395 bool result;
396
397 result = bms_overlap(bms1, bms2);
398
399 PG_RETURN_BOOL(result);
400}
401
402Datum
403 test_bms_overlap_list(PG_FUNCTION_ARGS)
404{
405 Bitmapset *bms;
406 ArrayType *array;
407 List *int_list = NIL;
408 bool result;
409 Datum *elem_datums = NULL;
410 bool *elem_nulls = NULL;
411 int elem_count;
412 int i;
413
414 bms = PG_ARG_GETBITMAPSET(0);
415
416 if (!PG_ARGISNULL(1))
417 {
418 array = PG_GETARG_ARRAYTYPE_P(1);
419
420 deconstruct_array(array,
421 INT4OID, sizeof(int32), true, 'i',
422 &elem_datums, &elem_nulls, &elem_count);
423
424 for (i = 0; i < elem_count; i++)
425 {
426 if (!elem_nulls[i])
427 {
428 int32 member = DatumGetInt32(elem_datums[i]);
429
430 int_list = lappend_int(int_list, member);
431 }
432 }
433 }
434
435 result = bms_overlap_list(bms, int_list);
436
437 list_free(int_list);
438
439 if (elem_datums)
440 pfree(elem_datums);
441
442 if (elem_nulls)
443 pfree(elem_nulls);
444
445 PG_RETURN_BOOL(result);
446}
447
448Datum
449 test_bms_nonempty_difference(PG_FUNCTION_ARGS)
450{
451 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
452 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
453 bool result;
454
455 result = bms_nonempty_difference(bms1, bms2);
456
457 PG_RETURN_BOOL(result);
458}
459
460Datum
461 test_bms_member_index(PG_FUNCTION_ARGS)
462{
463 Bitmapset *bms;
464 int32 member;
465 int result;
466
467 if (PG_ARGISNULL(1))
468 PG_RETURN_NULL(); /* invalid input */
469
470 bms = PG_ARG_GETBITMAPSET(0);
471 member = PG_GETARG_INT32(1);
472
473 result = bms_member_index(bms, member);
474
475 PG_RETURN_INT32(result);
476}
477
478Datum
479 test_bms_add_range(PG_FUNCTION_ARGS)
480{
481 Bitmapset *bms;
482 int32 lower,
483 upper;
484
485 if (PG_ARGISNULL(1) || PG_ARGISNULL(2))
486 PG_RETURN_NULL(); /* invalid input */
487
488 bms = PG_ARG_GETBITMAPSET(0);
489 lower = PG_GETARG_INT32(1);
490 upper = PG_GETARG_INT32(2);
491
492 bms = bms_add_range(bms, lower, upper);
493
494 PG_RETURN_BITMAPSET_AS_TEXT(bms);
495}
496
497Datum
498 test_bms_int_members(PG_FUNCTION_ARGS)
499{
500 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
501 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
502
503 /* left input gets recycled */
504 bms1 = bms_int_members(bms1, bms2);
505
506 PG_RETURN_BITMAPSET_AS_TEXT(bms1);
507}
508
509Datum
510 test_bms_del_members(PG_FUNCTION_ARGS)
511{
512 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
513 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
514
515 /* left input gets recycled */
516 bms1 = bms_del_members(bms1, bms2);
517
518 PG_RETURN_BITMAPSET_AS_TEXT(bms1);
519}
520
521Datum
522 test_bms_replace_members(PG_FUNCTION_ARGS)
523{
524 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
525 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
526
527 /* left input gets recycled */
528 bms1 = bms_replace_members(bms1, bms2);
529
530 PG_RETURN_BITMAPSET_AS_TEXT(bms1);
531}
532
533Datum
534 test_bms_join(PG_FUNCTION_ARGS)
535{
536 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
537 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
538 Bitmapset *result_bms;
539
540 /* either input can be recycled */
541 result_bms = bms_join(bms1, bms2);
542
543 PG_RETURN_BITMAPSET_AS_TEXT(result_bms);
544}
545
546Datum
547 test_bms_hash_value(PG_FUNCTION_ARGS)
548{
549 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
550 uint32 hash_result;
551
552 hash_result = bms_hash_value(bms);
553
554 PG_RETURN_INT32(hash_result);
555}
556
557Datum
558 test_bitmap_hash(PG_FUNCTION_ARGS)
559{
560 Bitmapset *bms = PG_ARG_GETBITMAPSET(0);
561 uint32 hash_result;
562
563 /* Call bitmap_hash */
564 hash_result = bitmap_hash(&bms, sizeof(Bitmapset *));
565
566 PG_RETURN_INT32(hash_result);
567}
568
569Datum
570 test_bitmap_match(PG_FUNCTION_ARGS)
571{
572 Bitmapset *bms1 = PG_ARG_GETBITMAPSET(0);
573 Bitmapset *bms2 = PG_ARG_GETBITMAPSET(1);
574 int match_result;
575
576 /* Call bitmap_match with addresses of the Bitmapset pointers */
577 match_result = bitmap_match(&bms1, &bms2, sizeof(Bitmapset *));
578
579 PG_RETURN_INT32(match_result);
580}
581
582/*
583 * Contrary to all the other functions which are one-one mappings with the
584 * equivalent C functions, this stresses Bitmapsets in a random fashion for
585 * various operations.
586 *
587 * "min_value" is the minimal value used for the members, that will stand
588 * up to a range of "max_range". "num_ops" defines the number of time each
589 * operation is done. "seed" is a random seed used to calculate the member
590 * values. When "seed" is <= 0, a random seed will be chosen automatically.
591 *
592 * The return value is the number of times all operations have been executed.
593 */
594Datum
595 test_random_operations(PG_FUNCTION_ARGS)
596{
597 Bitmapset *bms1 = NULL;
598 Bitmapset *bms2 = NULL;
599 Bitmapset *bms = NULL;
600 Bitmapset *result = NULL;
601 pg_prng_state state;
602 uint64 seed = GetCurrentTimestamp();
603 int num_ops;
604 int max_range;
605 int min_value;
606 int member;
607 int *members;
608 int num_members = 0;
609 int total_ops = 0;
610
611 if (PG_GETARG_INT32(0) > 0)
612 seed = PG_GETARG_INT32(0);
613
614 num_ops = PG_GETARG_INT32(1);
615 max_range = PG_GETARG_INT32(2);
616 min_value = PG_GETARG_INT32(3);
617
618 pg_prng_seed(&state, seed);
619 members = palloc(sizeof(int) * num_ops);
620
621 /* Phase 1: Random insertions */
622 for (int i = 0; i < num_ops / 2; i++)
623 {
624 member = pg_prng_uint32(&state) % max_range + min_value;
625
626 if (!bms_is_member(member, bms1))
627 {
628 members[num_members++] = member;
629 bms1 = bms_add_member(bms1, member);
630 }
631 }
632
633 /* Phase 2: Random set operations */
634 for (int i = 0; i < num_ops / 4; i++)
635 {
636 member = pg_prng_uint32(&state) % max_range + min_value;
637
638 bms2 = bms_add_member(bms2, member);
639 }
640
641 /* Test union */
642 result = bms_union(bms1, bms2);
643 EXPECT_NOT_NULL(result);
644
645 /* Verify union contains all members from first set */
646 for (int i = 0; i < num_members; i++)
647 {
648 if (!bms_is_member(members[i], result))
649 elog(ERROR, "union missing member %d", members[i]);
650 }
651 bms_free(result);
652
653 /* Test intersection */
654 result = bms_intersect(bms1, bms2);
655 if (result != NULL)
656 {
657 member = -1;
658
659 while ((member = bms_next_member(result, member)) >= 0)
660 {
661 if (!bms_is_member(member, bms1) || !bms_is_member(member, bms2))
662 elog(ERROR, "intersection contains invalid member %d", member);
663 }
664 bms_free(result);
665 }
666
667 /* Phase 3: Test range operations */
668 result = NULL;
669 for (int i = 0; i < num_ops; i++)
670 {
671 int lower = pg_prng_uint32(&state) % 100;
672 int upper = lower + (pg_prng_uint32(&state) % 20);
673
674 result = bms_add_range(result, lower, upper);
675 }
676 if (result != NULL)
677 {
678 EXPECT_TRUE(bms_num_members(result) > 0);
679 bms_free(result);
680 }
681
682 pfree(members);
683 bms_free(bms1);
684 bms_free(bms2);
685
686 for (int i = 0; i < num_ops; i++)
687 {
688 member = pg_prng_uint32(&state) % max_range + min_value;
689 switch (pg_prng_uint32(&state) % 3)
690 {
691 case 0: /* add */
692 bms = bms_add_member(bms, member);
693 break;
694 case 1: /* delete */
695 if (bms != NULL)
696 {
697 bms = bms_del_member(bms, member);
698 }
699 break;
700 case 2: /* test membership */
701 if (bms != NULL)
702 {
703 bms_is_member(member, bms);
704 }
705 break;
706 }
707 total_ops++;
708 }
709
710 bms_free(bms);
711
712 PG_RETURN_INT32(total_ops);
713}
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:263
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3631
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1645
Bitmapset * bms_replace_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:972
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:346
int bms_prev_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1367
Bitmapset * bms_make_singleton(int x)
Definition: bitmapset.c:216
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:1109
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:292
uint32 bitmap_hash(const void *key, Size keysize)
Definition: bitmapset.c:1436
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:142
BMS_Comparison bms_subset_compare(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:445
int bms_next_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1306
uint32 bms_hash_value(const Bitmapset *a)
Definition: bitmapset.c:1420
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:1161
Bitmapset * bms_add_range(Bitmapset *a, int lower, int upper)
Definition: bitmapset.c:1019
Bitmapset * bms_del_member(Bitmapset *a, int x)
Definition: bitmapset.c:868
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:412
int bms_singleton_member(const Bitmapset *a)
Definition: bitmapset.c:672
void bms_free(Bitmapset *a)
Definition: bitmapset.c:239
int bms_num_members(const Bitmapset *a)
Definition: bitmapset.c:751
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:815
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:917
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:251
int bitmap_match(const void *key1, const void *key2, Size keysize)
Definition: bitmapset.c:1446
BMS_Membership bms_membership(const Bitmapset *a)
Definition: bitmapset.c:781
int bms_member_index(Bitmapset *a, int x)
Definition: bitmapset.c:539
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:582
int bms_compare(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:183
bool bms_get_singleton_member(const Bitmapset *a, int *member)
Definition: bitmapset.c:715
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
Definition: bitmapset.c:1230
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:641
Bitmapset * bms_copy(const Bitmapset *a)
Definition: bitmapset.c:122
bool bms_overlap_list(const Bitmapset *a, const List *b)
Definition: bitmapset.c:608
#define bms_is_empty(a)
Definition: bitmapset.h:118
BMS_Comparison
Definition: bitmapset.h:61
BMS_Membership
Definition: bitmapset.h:70
int32_t int32
Definition: c.h:534
uint64_t uint64
Definition: c.h:539
uint32_t uint32
Definition: c.h:538
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define PG_ARGISNULL(n)
Definition: fmgr.h:209
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define PG_RETURN_INT32(x)
Definition: fmgr.h:354
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
i
int i
Definition: isn.c:77
List * lappend_int(List *list, int datum)
Definition: list.c:357
void list_free(List *list)
Definition: list.c:1546
void pfree(void *pointer)
Definition: mcxt.c:1594
void * palloc(Size size)
Definition: mcxt.c:1365
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:49
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:80
#define NIL
Definition: pg_list.h:68
uint32 pg_prng_uint32(pg_prng_state *state)
Definition: pg_prng.c:227
void pg_prng_seed(pg_prng_state *state, uint64 seed)
Definition: pg_prng.c:89
uint64_t Datum
Definition: postgres.h:70
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:212
Definition: array.h:93
Definition: pg_list.h:54
Definition: regguts.h:323
Datum test_bms_compare(PG_FUNCTION_ARGS)
Datum test_bms_difference(PG_FUNCTION_ARGS)
Datum test_random_operations(PG_FUNCTION_ARGS)
#define PG_RETURN_BITMAPSET_AS_TEXT(bms)
Datum test_bms_hash_value(PG_FUNCTION_ARGS)
#define EXPECT_TRUE(expr)
Definition: test_bitmapset.c:70
Datum test_bms_del_member(PG_FUNCTION_ARGS)
Datum test_bitmap_match(PG_FUNCTION_ARGS)
Datum test_bms_is_member(PG_FUNCTION_ARGS)
#define PG_ARG_GETBITMAPSET(n)
Definition: test_bitmapset.c:94
Datum test_bms_is_empty(PG_FUNCTION_ARGS)
Datum test_bms_add_member(PG_FUNCTION_ARGS)
Datum test_bms_int_members(PG_FUNCTION_ARGS)
Datum test_bms_add_members(PG_FUNCTION_ARGS)
PG_MODULE_MAGIC
Definition: test_bitmapset.c:30
Datum test_bitmap_hash(PG_FUNCTION_ARGS)
Datum test_bms_member_index(PG_FUNCTION_ARGS)
Datum test_bms_singleton_member(PG_FUNCTION_ARGS)
Datum test_bms_overlap_list(PG_FUNCTION_ARGS)
Datum test_bms_subset_compare(PG_FUNCTION_ARGS)
Datum test_bms_overlap(PG_FUNCTION_ARGS)
Datum test_bms_join(PG_FUNCTION_ARGS)
#define EXPECT_NOT_NULL(expr)
Definition: test_bitmapset.c:78
Datum test_bms_prev_member(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(test_bms_make_singleton)
Datum test_bms_equal(PG_FUNCTION_ARGS)
Datum test_bms_add_range(PG_FUNCTION_ARGS)
Datum test_bms_copy(PG_FUNCTION_ARGS)
Datum test_bms_make_singleton(PG_FUNCTION_ARGS)
Datum test_bms_replace_members(PG_FUNCTION_ARGS)
Datum test_bms_get_singleton_member(PG_FUNCTION_ARGS)
Datum test_bms_num_members(PG_FUNCTION_ARGS)
Datum test_bms_next_member(PG_FUNCTION_ARGS)
Datum test_bms_membership(PG_FUNCTION_ARGS)
Datum test_bms_union(PG_FUNCTION_ARGS)
Datum test_bms_intersect(PG_FUNCTION_ARGS)
Datum test_bms_del_members(PG_FUNCTION_ARGS)
Datum test_bms_is_subset(PG_FUNCTION_ARGS)
Datum test_bms_nonempty_difference(PG_FUNCTION_ARGS)

AltStyle によって変換されたページ (->オリジナル) /