public inbox for [email protected]help / color / mirror / Atom feed
[PATCH 1/8] introduce bsearch_arg 97+ messages / 2 participants [nested] [flat]
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------D524CD37E77B36A2883A7617 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210311.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------AC3FFB734F56C5F52D422EFC Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210305.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} -- 2.26.2 --------------82D677E9F94AC7574E460205 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-funct-20210308.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [PATCH 1/8] introduce bsearch_arg @ 2021-03-04 23:16 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Tomas Vondra @ 2021-03-04 23:16 UTC (permalink / raw) --- src/backend/statistics/extended_stats.c | 31 -------------- src/include/port.h | 5 +++ .../statistics/extended_stats_internal.h | 5 --- src/port/Makefile | 1 + src/port/bsearch_arg.c | 40 +++++++++++++++++++ src/tools/msvc/Mkvcbuild.pm | 2 +- 6 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 src/port/bsearch_arg.c diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index a030ea3653..fa42851fd5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -659,37 +659,6 @@ compare_datums_simple(Datum a, Datum b, SortSupport ssup) return ApplySortComparator(a, false, b, false, ssup); } -/* simple counterpart to qsort_arg */ -void * -bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg) -{ - size_t l, - u, - idx; - const void *p; - int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (void *) (((const char *) base) + (idx * size)); - comparison = (*compar) (key, p, arg); - - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (void *) p; - } - - return NULL; -} - /* * build_attnums_array * Transforms a bitmap into an array of AttrNumber values. diff --git a/src/include/port.h b/src/include/port.h index 227ef4b148..82f63de325 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -508,6 +508,11 @@ typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); extern void qsort_arg(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg); +extern void *bsearch_arg(const void *key, const void *base, + size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg); + /* port/chklocale.c */ extern int pg_get_encoding_from_locale(const char *ctype, bool write_message); diff --git a/src/include/statistics/extended_stats_internal.h b/src/include/statistics/extended_stats_internal.h index c849bd57c0..a0a3cf5b0f 100644 --- a/src/include/statistics/extended_stats_internal.h +++ b/src/include/statistics/extended_stats_internal.h @@ -85,11 +85,6 @@ extern int multi_sort_compare_dims(int start, int end, const SortItem *a, extern int compare_scalars_simple(const void *a, const void *b, void *arg); extern int compare_datums_simple(Datum a, Datum b, SortSupport ssup); -extern void *bsearch_arg(const void *key, const void *base, - size_t nmemb, size_t size, - int (*compar) (const void *, const void *, void *), - void *arg); - extern AttrNumber *build_attnums_array(Bitmapset *attrs, int *numattrs); extern SortItem *build_sorted_items(int numrows, int *nitems, HeapTuple *rows, diff --git a/src/port/Makefile b/src/port/Makefile index e41b005c4f..52dbf5783f 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -40,6 +40,7 @@ LIBS += $(PTHREAD_LIBS) OBJS = \ $(LIBOBJS) \ $(PG_CRC32C_OBJS) \ + bsearch_arg.o \ chklocale.o \ erand48.o \ inet_net_ntop.o \ diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c new file mode 100644 index 0000000000..d24dc4b7c4 --- /dev/null +++ b/src/port/bsearch_arg.c @@ -0,0 +1,40 @@ +/* + * bsearch_arg.c: bsearch variant with a user-supplied pointer + * + * src/port/bsearch_arg.c + */ + + +#include "c.h" + + +/* simple counterpart to qsort_arg */ +void * +bsearch_arg(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *, void *), + void *arg) +{ + size_t l, + u, + idx; + const void *p; + int comparison; + + l = 0; + u = nmemb; + while (l < u) + { + idx = (l + u) / 2; + p = (void *) (((const char *) base) + (idx * size)); + comparison = (*compar) (key, p, arg); + + if (comparison < 0) + u = idx; + else if (comparison > 0) + l = idx + 1; + else + return (void *) p; + } + + return NULL; +} diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 49614106dc..20221c1ae3 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -101,7 +101,7 @@ sub mkvcbuild dirent.c dlopen.c getopt.c getopt_long.c link.c pread.c preadv.c pwrite.c pwritev.c pg_bitutils.c pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c - pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c + pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c strerror.c tar.c thread.c win32env.c win32error.c win32security.c win32setlocale.c win32stat.c); -- 2.26.2 --------------556A1DC61262AF15641DB204 Content-Type: text/x-patch; charset=UTF-8; name="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Pass-all-scan-keys-to-BRIN-consistent-func-20210308b.pa"; filename*1="tch" ^ permalink raw reply [nested|flat] 97+ messages in thread
* [multithreading] extension compatibility @ 2024-06-05 20:05 Robert Haas <[email protected]> 0 siblings, 0 replies; 97+ messages in thread From: Robert Haas @ 2024-06-05 20:05 UTC (permalink / raw) To: pgsql-hackers; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; hlinnaka <[email protected]> Hi, At 2024.pgconf.dev, Heikki did a session on multithreading PostgreSQL which I was unfortunately unable to attend due my involvement with another session, and then we had an unconference discussion which I was able to attend and at which I volunteered to have a look at a couple of tasks, including "Extension Marking System (marking extensions as thread-safe)". So in this email I'd like to (1) say a few things about multithreading for PostgreSQL in general, (2) spell out my understanding of the extension compatibility problem specifically, and then (3) discuss possible solutions to that problem. See also https://wiki.postgresql.org/wiki/Multithreading == Multithreading Generally == I believe there is a consensus in the PostgreSQL developer community, or at least among committers, that a multi-threaded programming model would be superior to a multi-process programming model as we have now. I won't be surprised if a few people disagree with that as a general statement, and others may view it as better in theory but so difficult in practice as to be not worth doing, but I believe that the consensus is otherwise. I do understand that switching to threads introduces some new stability risks, which are not to be taken lightly, but it also opens the door to various performance improvements, and even functionality, that are not feasible today. I do not believe that it would be necessary, as has been alleged previously, to halt all other development for a lengthy period of time while such a conversion is undertaken, nor do I believe that the community would or should accept such a solution were someone to propose it. I do believe that there are some difficult problems to be solved in order to make it work at all, and I believe even more strongly that a good deal of follow-up work will be necessary to reap the potential benefits of such a change. I also believe that it's absolutely necessary that both models coexist side by side for a period of time. I think we will eventually want to abandon the multi-process model, because I think over time the benefits of using threads will accumulate until they are overwhelming and the process model will end up appearing to be an obstacle to progress. However, I don't think we'll be able to do that particularly soon, because I think it's going to take a while to fully stabilize the thread model even as far as the core code is concerned, and extensions will take even longer to catch up. I realize Heikki in particular is hoping for a quick transition; I don't see that as feasible, but like everything else about this, opinions are going to vary. Obligatory disclaimer: Everything above (and below) is just a statement of what I believe, and everyone is free to dispute it. As always, I cannot speak to objective truth, but I can tell you what I think. == The Extension Compatibility Problem == I don't know yet whether we're going to end up with a system where the same build of PostgreSQL can produce processes or threads depending on configuration or whether it's going to be a build option, but I'm guessing the latter is more likely. Certainly, if an extension is assuming that its global variables are session-local and they suddenly become global to the cluster, chaos will ensue. The same is true for the core code, and will need to be solved by annotating global variables so that the appropriate ones can be made thread-local and the others can be given whatever treatment is appropriate considering how they are used. The details of how this annotation system will work are TBD, but the point for this email is that extension global variables, including file-level globals, will need the same kinds of annotations that we use in the core code in order to work. Other adjustments may also be needed. I think there are two severable problems here. One is that, if an extension is built for use with a non-threaded PostgreSQL, we shouldn't permit it to be used with a threaded PostgreSQL, even if the major version and other details are compatible. Hence, threading or the lack of it must become part of the data set up by PG_MODULE_MAGIC. Maybe this problem goes away if we decide that threads-vs-processes is a configuration option rather than a build-time option, but even then, we might still end up with a build-time option indicating whether threads are even a possibility, so I think it's pretty likely we need this in some form. If or when the process model eventually dies, then we can take this out again. The other problem is that we probably want a way for extensions to signal that they are believed to work with threading. It's a little bit debatable whether this is a good idea, because (1) some people are going to blindly state that their extension works fine with threading even if they haven't actually made the necessary changes and (2) one could simply declare that making an extension thread-ready is part of supporting whatever PostgreSQL release adds threading as an option and (3) one could also declare that extension authors should just document what they do or don't support rather than doing anything in code. However, I think it makes sense to try to make extensions fail to compile against a threaded PostgreSQL unless the extension declares that it supports such builds of PostgreSQL. I think that by doing this, we'll make it a LOT easier for packagers to find out what extensions still need updating. A packager could possibly do light testing of an extension and fail to miss the fact that the extension doesn't actually work properly against a threaded PostgreSQL, but you can't fail to notice a compile failure. There's still going to be some chaos because of (1), but I think we can mitigate that with good messaging: documentation, wiki pages, and blog posts explaining that this is coming and how to adapt to it can help a lot, IMHO. == Extension Compatibility Solutions == The attached patch is a sketch of one possible approach: PostgreSQL signals whether it is multithreaded by defining or not defining PG_MULTITHREADING in pg_config_manual.h, and an extension signals thread-readiness by defining PG_THREADSAFE_EXTENSION before including any PostgreSQL headers other than postgres.h. If PostgreSQL is built multithreaded and the extension does not signal thread-safety, you get something like this: ../pgsql/src/test/modules/dummy_seclabel/dummy_seclabel.c:20:1: error: static assertion failed due to requirement '1 == 0': must define PG_THREADSAFE_EXTENSION or use unthreaded PostgreSQL PG_MODULE_MAGIC; I'm not entirely happy with this solution because the results are confusing if PG_THREADSAFE_EXTENSION is declared after including fmgr.h. Perhaps this can be adequately handled by documenting and demonstrating the right pattern, or maybe somebody has a better idea. Another idea I considered was to replace the PG_MODULE_MAGIC; declaration with something that allows for arguments, like PG_MODULE_MAGIC(.process_model = false, .thread_model = true). But on further reflection, that seems like the wrong thing. AFAICS, that's going to tell you at runtime about something that you really want to know at compile time. But this kind of idea might need more thought if we decide that the *same* build of PostgreSQL can either launch processes or threads per session, because then we'd to know which extensions were available in whichever mode applied to the current session. That's all I've got for today. -- Robert Haas EDB: http://www.enterprisedb.com Attachments: [application/octet-stream] v1-0001-POC-Extension-API-for-multithreading.patch (56.2K, ../../CA+TgmoYsKJnVjj94HJTSOeS1=TmAgV5L=DVTd_TYL=XUKCbfEA@mail.gmail.com/2-v1-0001-POC-Extension-API-for-multithreading.patch) download | inline diff: From b7d50a58dba4c780e144610a95e80b808cc963b6 Mon Sep 17 00:00:00 2001 From: Robert Haas <[email protected]> Date: Wed, 5 Jun 2024 13:45:08 -0400 Subject: [PATCH v1] POC: Extension API for multithreading. Calling this a POC is probably ambitious, but it illustrates one possible approach to the problem: extensions can define PG_THREADSAFE_EXTENSION before including any PostgreSQL headers other than "postgres.h"; if they don't, they won't compile if PG_MULTITHREADING was defined when building the server Also, an extension built against a PG_MULTITHREADING PostgreSQL cannot be loaded into one built without that #define, and the other way around. Doing so will produce a complaint, similar to a library version mismatch. --- contrib/amcheck/verify_nbtree.c | 2 ++ contrib/auth_delay/auth_delay.c | 2 ++ contrib/auto_explain/auto_explain.c | 2 ++ .../basebackup_to_shell/basebackup_to_shell.c | 2 ++ contrib/basic_archive/basic_archive.c | 2 ++ contrib/bloom/blinsert.c | 2 ++ contrib/bool_plperl/bool_plperl.c | 2 ++ contrib/btree_gin/btree_gin.c | 2 ++ contrib/btree_gist/btree_gist.c | 2 ++ contrib/citext/citext.c | 2 ++ contrib/cube/cube.c | 2 ++ contrib/dblink/dblink.c | 2 ++ contrib/dict_int/dict_int.c | 2 ++ contrib/dict_xsyn/dict_xsyn.c | 2 ++ contrib/earthdistance/earthdistance.c | 2 ++ contrib/file_fdw/file_fdw.c | 2 ++ contrib/fuzzystrmatch/fuzzystrmatch.c | 2 ++ contrib/hstore/hstore_io.c | 2 ++ contrib/hstore_plperl/hstore_plperl.c | 2 ++ contrib/hstore_plpython/hstore_plpython.c | 2 ++ contrib/intarray/_int_op.c | 2 ++ contrib/isn/isn.c | 2 ++ contrib/jsonb_plperl/jsonb_plperl.c | 2 ++ contrib/jsonb_plpython/jsonb_plpython.c | 2 ++ contrib/lo/lo.c | 2 ++ contrib/ltree/ltree_op.c | 2 ++ contrib/ltree_plpython/ltree_plpython.c | 2 ++ contrib/pageinspect/rawpage.c | 2 ++ contrib/passwordcheck/passwordcheck.c | 2 ++ contrib/pg_buffercache/pg_buffercache_pages.c | 2 ++ contrib/pg_freespacemap/pg_freespacemap.c | 2 ++ contrib/pg_prewarm/pg_prewarm.c | 2 ++ .../pg_stat_statements/pg_stat_statements.c | 2 ++ contrib/pg_surgery/heap_surgery.c | 2 ++ contrib/pg_trgm/trgm_op.c | 2 ++ contrib/pg_visibility/pg_visibility.c | 2 ++ contrib/pg_walinspect/pg_walinspect.c | 2 ++ contrib/pgcrypto/pgcrypto.c | 2 ++ contrib/pgrowlocks/pgrowlocks.c | 2 ++ contrib/pgstattuple/pgstattuple.c | 2 ++ contrib/postgres_fdw/postgres_fdw.c | 2 ++ contrib/seg/seg.c | 2 ++ contrib/sepgsql/hooks.c | 2 ++ contrib/spi/autoinc.c | 2 ++ contrib/spi/insert_username.c | 2 ++ contrib/spi/moddatetime.c | 2 ++ contrib/spi/refint.c | 2 ++ contrib/sslinfo/sslinfo.c | 2 ++ contrib/tablefunc/tablefunc.c | 2 ++ contrib/tcn/tcn.c | 2 ++ contrib/test_decoding/test_decoding.c | 2 ++ contrib/tsm_system_rows/tsm_system_rows.c | 2 ++ contrib/tsm_system_time/tsm_system_time.c | 2 ++ contrib/unaccent/unaccent.c | 2 ++ contrib/uuid-ossp/uuid-ossp.c | 2 ++ contrib/xml2/xpath.c | 2 ++ .../libpqwalreceiver/libpqwalreceiver.c | 2 ++ src/backend/replication/pgoutput/pgoutput.c | 2 ++ src/backend/snowball/dict_snowball.c | 2 ++ .../cyrillic_and_mic/cyrillic_and_mic.c | 3 +++ .../euc2004_sjis2004/euc2004_sjis2004.c | 3 +++ .../euc_cn_and_mic/euc_cn_and_mic.c | 3 +++ .../euc_jp_and_sjis/euc_jp_and_sjis.c | 3 +++ .../euc_kr_and_mic/euc_kr_and_mic.c | 3 +++ .../euc_tw_and_big5/euc_tw_and_big5.c | 3 +++ .../latin2_and_win1250/latin2_and_win1250.c | 3 +++ .../latin_and_mic/latin_and_mic.c | 3 +++ .../utf8_and_big5/utf8_and_big5.c | 3 +++ .../utf8_and_cyrillic/utf8_and_cyrillic.c | 3 +++ .../utf8_and_euc2004/utf8_and_euc2004.c | 3 +++ .../utf8_and_euc_cn/utf8_and_euc_cn.c | 3 +++ .../utf8_and_euc_jp/utf8_and_euc_jp.c | 3 +++ .../utf8_and_euc_kr/utf8_and_euc_kr.c | 3 +++ .../utf8_and_euc_tw/utf8_and_euc_tw.c | 3 +++ .../utf8_and_gb18030/utf8_and_gb18030.c | 3 +++ .../utf8_and_gbk/utf8_and_gbk.c | 3 +++ .../utf8_and_iso8859/utf8_and_iso8859.c | 3 +++ .../utf8_and_iso8859_1/utf8_and_iso8859_1.c | 3 +++ .../utf8_and_johab/utf8_and_johab.c | 3 +++ .../utf8_and_sjis/utf8_and_sjis.c | 3 +++ .../utf8_and_sjis2004/utf8_and_sjis2004.c | 3 +++ .../utf8_and_uhc/utf8_and_uhc.c | 3 +++ .../utf8_and_win/utf8_and_win.c | 3 +++ src/include/fmgr.h | 19 +++++++++++++++++++ src/include/pg_config_manual.h | 5 +++++ src/pl/plperl/plperl.c | 1 + src/pl/plpgsql/src/pl_handler.c | 2 ++ src/pl/plpython/plpy_main.c | 2 ++ src/pl/tcl/pltcl.c | 2 ++ .../modules/delay_execution/delay_execution.c | 2 ++ .../modules/dummy_index_am/dummy_index_am.c | 2 ++ .../modules/dummy_seclabel/dummy_seclabel.c | 2 ++ .../injection_points/injection_points.c | 2 ++ .../ldap_password_func/ldap_password_func.c | 2 ++ src/test/modules/plsample/plsample.c | 2 ++ .../modules/spgist_name_ops/spgist_name_ops.c | 2 ++ .../ssl_passphrase_func.c | 2 ++ .../test_bloomfilter/test_bloomfilter.c | 2 ++ .../test_copy_callbacks/test_copy_callbacks.c | 2 ++ .../test_custom_rmgrs/test_custom_rmgrs.c | 2 ++ .../test_ddl_deparse/test_ddl_deparse.c | 2 ++ src/test/modules/test_dsa/test_dsa.c | 2 ++ .../test_dsm_registry/test_dsm_registry.c | 2 ++ .../test_ginpostinglist/test_ginpostinglist.c | 2 ++ .../modules/test_integerset/test_integerset.c | 2 ++ src/test/modules/test_lfind/test_lfind.c | 2 ++ .../modules/test_oat_hooks/test_oat_hooks.c | 2 ++ src/test/modules/test_parser/test_parser.c | 2 ++ .../modules/test_predtest/test_predtest.c | 2 ++ .../modules/test_radixtree/test_radixtree.c | 2 ++ src/test/modules/test_rbtree/test_rbtree.c | 2 ++ src/test/modules/test_regex/test_regex.c | 2 ++ .../test_resowner/test_resowner_basic.c | 2 ++ .../modules/test_rls_hooks/test_rls_hooks.c | 2 ++ src/test/modules/test_shm_mq/test.c | 2 ++ src/test/modules/test_slru/test_slru.c | 2 ++ .../modules/test_tidstore/test_tidstore.c | 2 ++ src/test/modules/worker_spi/worker_spi.c | 2 ++ .../modules/xid_wraparound/xid_wraparound.c | 2 ++ src/test/regress/regress.c | 2 ++ 120 files changed, 283 insertions(+) diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index 70f65b645a..40b69b6b0e 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -23,6 +23,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/heaptoast.h" #include "access/htup_details.h" #include "access/nbtree.h" diff --git a/contrib/auth_delay/auth_delay.c b/contrib/auth_delay/auth_delay.c index ff0e1fd461..890c7cdf45 100644 --- a/contrib/auth_delay/auth_delay.c +++ b/contrib/auth_delay/auth_delay.c @@ -13,6 +13,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "libpq/auth.h" #include "port.h" #include "utils/guc.h" diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index 677c135f59..b875e9d374 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -14,6 +14,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/parallel.h" #include "commands/explain.h" #include "common/pg_prng.h" diff --git a/contrib/basebackup_to_shell/basebackup_to_shell.c b/contrib/basebackup_to_shell/basebackup_to_shell.c index fe419d9080..0a956c20a2 100644 --- a/contrib/basebackup_to_shell/basebackup_to_shell.c +++ b/contrib/basebackup_to_shell/basebackup_to_shell.c @@ -10,6 +10,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/xact.h" #include "backup/basebackup_target.h" #include "common/percentrepl.h" diff --git a/contrib/basic_archive/basic_archive.c b/contrib/basic_archive/basic_archive.c index 028cf51c25..bfba902f71 100644 --- a/contrib/basic_archive/basic_archive.c +++ b/contrib/basic_archive/basic_archive.c @@ -30,6 +30,8 @@ #include <sys/time.h> #include <unistd.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "archive/archive_module.h" #include "common/int.h" #include "miscadmin.h" diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c index f8a1061abb..ce19e25ae0 100644 --- a/contrib/bloom/blinsert.c +++ b/contrib/bloom/blinsert.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/genam.h" #include "access/generic_xlog.h" #include "access/tableam.h" diff --git a/contrib/bool_plperl/bool_plperl.c b/contrib/bool_plperl/bool_plperl.c index 0fa1eee8e5..5c4557da38 100644 --- a/contrib/bool_plperl/bool_plperl.c +++ b/contrib/bool_plperl/bool_plperl.c @@ -1,5 +1,7 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "plperl.h" diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c index 5e27906f80..9641cb4424 100644 --- a/contrib/btree_gin/btree_gin.c +++ b/contrib/btree_gin/btree_gin.c @@ -5,6 +5,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/stratnum.h" #include "utils/builtins.h" #include "utils/bytea.h" diff --git a/contrib/btree_gist/btree_gist.c b/contrib/btree_gist/btree_gist.c index 92520aedae..fb48808ae9 100644 --- a/contrib/btree_gist/btree_gist.c +++ b/contrib/btree_gist/btree_gist.c @@ -3,6 +3,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "utils/builtins.h" PG_MODULE_MAGIC; diff --git a/contrib/citext/citext.c b/contrib/citext/citext.c index 26af935a70..ce6a0a4ce9 100644 --- a/contrib/citext/citext.c +++ b/contrib/citext/citext.c @@ -3,6 +3,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_collation.h" #include "common/hashfn.h" #include "utils/builtins.h" diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 1fc447511a..ed7fb3672d 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -10,6 +10,8 @@ #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/gist.h" #include "access/stratnum.h" #include "cubedata.h" diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 755293456f..393e6cb827 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -34,6 +34,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "access/relation.h" #include "access/reloptions.h" diff --git a/contrib/dict_int/dict_int.c b/contrib/dict_int/dict_int.c index 82f3c60251..cdc43257b8 100644 --- a/contrib/dict_int/dict_int.c +++ b/contrib/dict_int/dict_int.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/defrem.h" #include "tsearch/ts_public.h" diff --git a/contrib/dict_xsyn/dict_xsyn.c b/contrib/dict_xsyn/dict_xsyn.c index 62d2d84141..554c5c66a8 100644 --- a/contrib/dict_xsyn/dict_xsyn.c +++ b/contrib/dict_xsyn/dict_xsyn.c @@ -14,6 +14,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/defrem.h" #include "tsearch/ts_locale.h" #include "tsearch/ts_utils.h" diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c index ded048c8ac..2e697460b8 100644 --- a/contrib/earthdistance/earthdistance.c +++ b/contrib/earthdistance/earthdistance.c @@ -4,6 +4,8 @@ #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "utils/geo_decls.h" /* for Point */ /* X/Open (XSI) requires <math.h> to provide M_PI, but core POSIX does not */ diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 249d82d3a0..4f7807596b 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -15,6 +15,8 @@ #include <sys/stat.h> #include <unistd.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "access/reloptions.h" #include "access/sysattr.h" diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c index 72ae2ab91b..ae91a0abce 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.c +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c @@ -40,6 +40,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "mb/pg_wchar.h" #include "utils/builtins.h" #include "utils/varlena.h" diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index 999ddad76d..693e57a8df 100644 --- a/contrib/hstore/hstore_io.c +++ b/contrib/hstore/hstore_io.c @@ -5,6 +5,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "common/jsonapi.h" diff --git a/contrib/hstore_plperl/hstore_plperl.c b/contrib/hstore_plperl/hstore_plperl.c index 4a1629cad5..55f9951879 100644 --- a/contrib/hstore_plperl/hstore_plperl.c +++ b/contrib/hstore_plperl/hstore_plperl.c @@ -1,5 +1,7 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "hstore/hstore.h" #include "plperl.h" diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c index 310f63c30d..0aae12b512 100644 --- a/contrib/hstore_plpython/hstore_plpython.c +++ b/contrib/hstore_plpython/hstore_plpython.c @@ -1,5 +1,7 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "hstore/hstore.h" #include "plpy_typeio.h" diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c index 5b164f6788..fcadf10b38 100644 --- a/contrib/intarray/_int_op.c +++ b/contrib/intarray/_int_op.c @@ -3,6 +3,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "_int.h" PG_MODULE_MAGIC; diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c index 71a543b947..dc2a67d894 100644 --- a/contrib/isn/isn.c +++ b/contrib/isn/isn.c @@ -14,6 +14,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "EAN13.h" #include "ISBN.h" #include "ISMN.h" diff --git a/contrib/jsonb_plperl/jsonb_plperl.c b/contrib/jsonb_plperl/jsonb_plperl.c index 2af1e0c02a..f5a62a194b 100644 --- a/contrib/jsonb_plperl/jsonb_plperl.c +++ b/contrib/jsonb_plperl/jsonb_plperl.c @@ -2,6 +2,8 @@ #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "plperl.h" #include "utils/fmgrprotos.h" diff --git a/contrib/jsonb_plpython/jsonb_plpython.c b/contrib/jsonb_plpython/jsonb_plpython.c index a625727c5e..8e884dd08b 100644 --- a/contrib/jsonb_plpython/jsonb_plpython.c +++ b/contrib/jsonb_plpython/jsonb_plpython.c @@ -1,5 +1,7 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "plpy_elog.h" #include "plpy_typeio.h" #include "plpython.h" diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c index 457be26c4e..585cdc716a 100644 --- a/contrib/lo/lo.c +++ b/contrib/lo/lo.c @@ -7,6 +7,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/trigger.h" #include "executor/spi.h" #include "utils/builtins.h" diff --git a/contrib/ltree/ltree_op.c b/contrib/ltree/ltree_op.c index 24a21d3ea0..563b0f0d5e 100644 --- a/contrib/ltree/ltree_op.c +++ b/contrib/ltree/ltree_op.c @@ -7,6 +7,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_statistic.h" #include "common/hashfn.h" diff --git a/contrib/ltree_plpython/ltree_plpython.c b/contrib/ltree_plpython/ltree_plpython.c index ac159ea314..839c256af6 100644 --- a/contrib/ltree_plpython/ltree_plpython.c +++ b/contrib/ltree_plpython/ltree_plpython.c @@ -1,5 +1,7 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "ltree/ltree.h" #include "plpython.h" diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c index 2800ebd62f..e55d49ff43 100644 --- a/contrib/pageinspect/rawpage.c +++ b/contrib/pageinspect/rawpage.c @@ -15,6 +15,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "access/relation.h" #include "catalog/namespace.h" diff --git a/contrib/passwordcheck/passwordcheck.c b/contrib/passwordcheck/passwordcheck.c index 0785618f2a..3bd0b7cd66 100644 --- a/contrib/passwordcheck/passwordcheck.c +++ b/contrib/passwordcheck/passwordcheck.c @@ -20,6 +20,8 @@ #include <crack.h> #endif +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/user.h" #include "fmgr.h" #include "libpq/crypt.h" diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index 3ae0a018e1..9c9f5a70f9 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -8,6 +8,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "funcapi.h" diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c index b82cab2d97..409db4dfce 100644 --- a/contrib/pg_freespacemap/pg_freespacemap.c +++ b/contrib/pg_freespacemap/pg_freespacemap.c @@ -8,6 +8,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/relation.h" #include "funcapi.h" #include "storage/freespace.h" diff --git a/contrib/pg_prewarm/pg_prewarm.c b/contrib/pg_prewarm/pg_prewarm.c index 5c859e983c..34b61e7299 100644 --- a/contrib/pg_prewarm/pg_prewarm.c +++ b/contrib/pg_prewarm/pg_prewarm.c @@ -15,6 +15,8 @@ #include <sys/stat.h> #include <unistd.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/relation.h" #include "fmgr.h" #include "miscadmin.h" diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index d4197ae0f7..0939ae683a 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -47,6 +47,8 @@ #include <sys/stat.h> #include <unistd.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/parallel.h" #include "catalog/pg_authid.h" #include "common/hashfn.h" diff --git a/contrib/pg_surgery/heap_surgery.c b/contrib/pg_surgery/heap_surgery.c index 37dffe3f7d..d483741b0b 100644 --- a/contrib/pg_surgery/heap_surgery.c +++ b/contrib/pg_surgery/heap_surgery.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/heapam.h" #include "access/visibilitymap.h" #include "access/xloginsert.h" diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c index c509d15ee4..b26ed4472e 100644 --- a/contrib/pg_trgm/trgm_op.c +++ b/contrib/pg_trgm/trgm_op.c @@ -5,6 +5,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_type.h" #include "common/int.h" #include "lib/qunique.h" diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c index 1a1a4ff7be..0a72592055 100644 --- a/contrib/pg_visibility/pg_visibility.c +++ b/contrib/pg_visibility/pg_visibility.c @@ -10,6 +10,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/heapam.h" #include "access/htup_details.h" #include "access/visibilitymap.h" diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c index ee2918726d..a1f6e2cf18 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/xlog.h" #include "access/xlog_internal.h" #include "access/xlogreader.h" diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index 96447c5757..bf6bc3efdc 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -33,6 +33,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "parser/scansup.h" #include "pgcrypto.h" #include "px-crypt.h" diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c index adbc8279c3..4df8bc2618 100644 --- a/contrib/pgrowlocks/pgrowlocks.c +++ b/contrib/pgrowlocks/pgrowlocks.c @@ -24,6 +24,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/heapam.h" #include "access/multixact.h" #include "access/relscan.h" diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index 3bd8b96197..c1ea8d3e5c 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -24,6 +24,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/gist_private.h" #include "access/hash.h" #include "access/heapam.h" diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 4053cd641c..6f447c2a40 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -14,6 +14,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "access/sysattr.h" #include "access/table.h" diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 7f9fc24eb4..2326d700ae 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -12,6 +12,8 @@ #include <float.h> #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/gist.h" #include "access/stratnum.h" #include "fmgr.h" diff --git a/contrib/sepgsql/hooks.c b/contrib/sepgsql/hooks.c index 0f206b1093..645616a27a 100644 --- a/contrib/sepgsql/hooks.c +++ b/contrib/sepgsql/hooks.c @@ -10,6 +10,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/dependency.h" #include "catalog/objectaccess.h" #include "catalog/pg_class.h" diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c index 8bf742230e..4eaf12cfc7 100644 --- a/contrib/spi/autoinc.c +++ b/contrib/spi/autoinc.c @@ -3,6 +3,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "commands/sequence.h" diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c index a2e1747ff7..2a7be76df3 100644 --- a/contrib/spi/insert_username.c +++ b/contrib/spi/insert_username.c @@ -6,6 +6,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "commands/trigger.h" diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c index 3eb7004de9..a1cd5f92ba 100644 --- a/contrib/spi/moddatetime.c +++ b/contrib/spi/moddatetime.c @@ -15,6 +15,8 @@ OH, me, I'm Terry Mackintosh <[email protected]> */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "commands/trigger.h" diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index 18062eb1cf..0d28ec5b39 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -9,6 +9,8 @@ #include <ctype.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/trigger.h" #include "executor/spi.h" #include "utils/builtins.h" diff --git a/contrib/sslinfo/sslinfo.c b/contrib/sslinfo/sslinfo.c index 5fd46b9874..dce034f009 100644 --- a/contrib/sslinfo/sslinfo.c +++ b/contrib/sslinfo/sslinfo.c @@ -13,6 +13,8 @@ #include <openssl/x509v3.h> #include <openssl/asn1.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "funcapi.h" #include "libpq/libpq-be.h" diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 7d1b5f5143..7ba5a73be5 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -34,6 +34,8 @@ #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "common/pg_prng.h" diff --git a/contrib/tcn/tcn.c b/contrib/tcn/tcn.c index 8d23c824c1..342e46d022 100644 --- a/contrib/tcn/tcn.c +++ b/contrib/tcn/tcn.c @@ -15,6 +15,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "commands/async.h" #include "commands/trigger.h" diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index 7c50d13969..836bb1bc13 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_type.h" #include "replication/logical.h" diff --git a/contrib/tsm_system_rows/tsm_system_rows.c b/contrib/tsm_system_rows/tsm_system_rows.c index a9f5d657d1..80a83e3ea9 100644 --- a/contrib/tsm_system_rows/tsm_system_rows.c +++ b/contrib/tsm_system_rows/tsm_system_rows.c @@ -28,6 +28,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/relscan.h" #include "access/tsmapi.h" #include "catalog/pg_type.h" diff --git a/contrib/tsm_system_time/tsm_system_time.c b/contrib/tsm_system_time/tsm_system_time.c index f187fd7765..71c52785e8 100644 --- a/contrib/tsm_system_time/tsm_system_time.c +++ b/contrib/tsm_system_time/tsm_system_time.c @@ -26,6 +26,8 @@ #include <math.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/relscan.h" #include "access/tsmapi.h" #include "catalog/pg_type.h" diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c index 707962305f..586c3be52f 100644 --- a/contrib/unaccent/unaccent.c +++ b/contrib/unaccent/unaccent.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/namespace.h" #include "catalog/pg_ts_dict.h" #include "commands/defrem.h" diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c index 3172714eb6..bd182b9308 100644 --- a/contrib/uuid-ossp/uuid-ossp.c +++ b/contrib/uuid-ossp/uuid-ossp.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "common/cryptohash.h" #include "common/sha1.h" #include "fmgr.h" diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index b999b1f706..5deeb6e158 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -6,6 +6,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "executor/spi.h" #include "fmgr.h" diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index 3c2b1bb496..58f9078d28 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -22,6 +22,8 @@ #include <unistd.h> #include <sys/time.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "common/connect.h" #include "funcapi.h" #include "libpq-fe.h" diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index d2b35cfb96..b5b6e61e4d 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/tupconvert.h" #include "catalog/partition.h" #include "catalog/pg_publication.h" diff --git a/src/backend/snowball/dict_snowball.c b/src/backend/snowball/dict_snowball.c index caf8649068..896fa69914 100644 --- a/src/backend/snowball/dict_snowball.c +++ b/src/backend/snowball/dict_snowball.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/defrem.h" #include "tsearch/ts_locale.h" #include "tsearch/ts_public.h" diff --git a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c index aa61902a82..bce5c2733d 100644 --- a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/euc2004_sjis2004/euc2004_sjis2004.c b/src/backend/utils/mb/conversion_procs/euc2004_sjis2004/euc2004_sjis2004.c index 8f5fa90070..5fce0e5beb 100644 --- a/src/backend/utils/mb/conversion_procs/euc2004_sjis2004/euc2004_sjis2004.c +++ b/src/backend/utils/mb/conversion_procs/euc2004_sjis2004/euc2004_sjis2004.c @@ -11,6 +11,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c index 9551761a75..7872fa78ae 100644 --- a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c index daf6eac974..a1378d80df 100644 --- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c index 631766898f..88aa2c32a0 100644 --- a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c index ed71678c98..119f014a59 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c b/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c index a2f6c3f723..ae558ee337 100644 --- a/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c +++ b/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c b/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c index e00aa38228..099aa6dd0e 100644 --- a/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c index 62643aaa29..c43489a106 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/big5_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c index 9672954c8b..507be3803c 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/utf8_to_koi8r.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c index 25bc45cf37..2fded86f96 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc2004/utf8_and_euc2004.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/euc_jis_2004_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c index 3f5d2f3cb7..28c22a5ab1 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/euc_cn_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c index 837e7e98e9..0ca4a70d00 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/euc_jp_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c index 7ad7f26397..9ad51945a1 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/euc_kr_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c index 9e56f1fe24..2b948b0cf1 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/euc_tw_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c index c64c6d2b31..148f531af4 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/gb18030_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c index 696d741e91..87a93eebc5 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/gbk_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c index 20558de029..be35218485 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/iso8859_10_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c index 45d1504098..79c7557c84 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c index a0c13ae228..0f10596b18 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/johab_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c index e619fd932d..b9cbad0b29 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/sjis_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c b/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c index 5078475762..62346e9ab7 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_sjis2004/utf8_and_sjis2004.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/shift_jis_2004_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c index d6475c2197..4bced4818f 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/uhc_to_utf8.map" diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c b/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c index e813d894f9..b903f6f274 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c @@ -12,6 +12,9 @@ */ #include "postgres.h" + +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "mb/pg_wchar.h" #include "../../Unicode/utf8_to_win1250.map" diff --git a/src/include/fmgr.h b/src/include/fmgr.h index ccb4070a25..a6c61fa8bd 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -18,6 +18,8 @@ #ifndef FMGR_H #define FMGR_H +#include "pg_config_manual.h" + /* We don't want to include primnodes.h here, so make some stub references */ typedef struct Node *fmNodePtr; typedef struct Aggref *fmAggrefPtr; @@ -465,6 +467,7 @@ typedef struct { int len; /* sizeof(this struct) */ int version; /* PostgreSQL major version */ + int threading; /* 1 if PG_MULTITHREADING, else 0 */ int funcmaxargs; /* FUNC_MAX_ARGS */ int indexmaxkeys; /* INDEX_MAX_KEYS */ int namedatalen; /* NAMEDATALEN */ @@ -472,11 +475,26 @@ typedef struct char abi_extra[32]; /* see pg_config_manual.h */ } Pg_magic_struct; +#ifdef PG_MULTITHREADING +#define PG_MULTITHREADING_VALUE 1 +#else +#define PG_MULTITHREADING_VALUE 0 +#endif + +#ifdef PG_THREADSAFE_EXTENSION +#define PG_CHECK_THREAD_SAFETY +#else +#define PG_CHECK_THREAD_SAFETY \ + StaticAssertStmt(PG_MULTITHREADING_VALUE == 0, \ + "must define PG_THREADSAFE_EXTENSION or use unthreaded PostgreSQL") +#endif + /* The actual data block contents */ #define PG_MODULE_MAGIC_DATA \ { \ sizeof(Pg_magic_struct), \ PG_VERSION_NUM / 100, \ + PG_MULTITHREADING_VALUE, \ FUNC_MAX_ARGS, \ INDEX_MAX_KEYS, \ NAMEDATALEN, \ @@ -502,6 +520,7 @@ const Pg_magic_struct * \ PG_MAGIC_FUNCTION_NAME(void) \ { \ static const Pg_magic_struct Pg_magic_data = PG_MODULE_MAGIC_DATA; \ + PG_CHECK_THREAD_SAFETY; \ return &Pg_magic_data; \ } \ extern int no_such_variable diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index f941ee2faf..e7e4e92037 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -379,6 +379,11 @@ */ #define TRACE_SORT 1 +/* + * Enable multithreading support (works great, no bugs at all!). + */ +/* #define PG_MULTITHREADING 1 */ + /* * Enable tracing of syncscan operations (see also the trace_syncscan GUC var). */ diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index d68ad7be34..91fe7bfa34 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -14,6 +14,7 @@ #include <unistd.h> /* postgreSQL stuff */ +#define PG_THREADSAFE_EXTENSION 1 #include "access/htup_details.h" #include "access/xact.h" #include "catalog/pg_language.h" diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index fce459ade0..fddbdfd060 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -15,6 +15,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c index 010a97378c..a6618ce0e6 100644 --- a/src/pl/plpython/plpy_main.c +++ b/src/pl/plpython/plpy_main.c @@ -6,6 +6,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 18d14a2b98..5140c5c866 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -13,6 +13,8 @@ #include <unistd.h> #include <fcntl.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "access/xact.h" #include "catalog/objectaccess.h" diff --git a/src/test/modules/delay_execution/delay_execution.c b/src/test/modules/delay_execution/delay_execution.c index 155c8a8d55..745356bd5a 100644 --- a/src/test/modules/delay_execution/delay_execution.c +++ b/src/test/modules/delay_execution/delay_execution.c @@ -22,6 +22,8 @@ #include <limits.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "optimizer/planner.h" #include "utils/builtins.h" #include "utils/guc.h" diff --git a/src/test/modules/dummy_index_am/dummy_index_am.c b/src/test/modules/dummy_index_am/dummy_index_am.c index 18185d0206..22177538cd 100644 --- a/src/test/modules/dummy_index_am/dummy_index_am.c +++ b/src/test/modules/dummy_index_am/dummy_index_am.c @@ -13,6 +13,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/amapi.h" #include "access/reloptions.h" #include "catalog/index.h" diff --git a/src/test/modules/dummy_seclabel/dummy_seclabel.c b/src/test/modules/dummy_seclabel/dummy_seclabel.c index aded20e1be..e5de0ea94d 100644 --- a/src/test/modules/dummy_seclabel/dummy_seclabel.c +++ b/src/test/modules/dummy_seclabel/dummy_seclabel.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "commands/seclabel.h" #include "fmgr.h" #include "miscadmin.h" diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c index 5c44625d1d..ca134fb364 100644 --- a/src/test/modules/injection_points/injection_points.c +++ b/src/test/modules/injection_points/injection_points.c @@ -17,6 +17,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "miscadmin.h" #include "nodes/pg_list.h" diff --git a/src/test/modules/ldap_password_func/ldap_password_func.c b/src/test/modules/ldap_password_func/ldap_password_func.c index 99c18a8f1c..964335eb43 100644 --- a/src/test/modules/ldap_password_func/ldap_password_func.c +++ b/src/test/modules/ldap_password_func/ldap_password_func.c @@ -15,6 +15,8 @@ #include <float.h> #include <stdio.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "libpq/auth.h" #include "libpq/libpq.h" #include "libpq/libpq-be.h" diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c index 40c462e84e..c95a59387c 100644 --- a/src/test/modules/plsample/plsample.c +++ b/src/test/modules/plsample/plsample.c @@ -15,6 +15,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_proc.h" #include "catalog/pg_type.h" #include "commands/event_trigger.h" diff --git a/src/test/modules/spgist_name_ops/spgist_name_ops.c b/src/test/modules/spgist_name_ops/spgist_name_ops.c index 322881ba78..99490be3eb 100644 --- a/src/test/modules/spgist_name_ops/spgist_name_ops.c +++ b/src/test/modules/spgist_name_ops/spgist_name_ops.c @@ -21,6 +21,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/spgist.h" #include "catalog/pg_type.h" #include "utils/datum.h" diff --git a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c index d599214982..0e3f38e2a6 100644 --- a/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c +++ b/src/test/modules/ssl_passphrase_callback/ssl_passphrase_func.c @@ -14,6 +14,8 @@ #include <float.h> #include <stdio.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "libpq/libpq.h" #include "libpq/libpq-be.h" #include "utils/guc.h" diff --git a/src/test/modules/test_bloomfilter/test_bloomfilter.c b/src/test/modules/test_bloomfilter/test_bloomfilter.c index b0633a8fa7..992930697a 100644 --- a/src/test/modules/test_bloomfilter/test_bloomfilter.c +++ b/src/test/modules/test_bloomfilter/test_bloomfilter.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "common/pg_prng.h" #include "fmgr.h" #include "lib/bloomfilter.h" diff --git a/src/test/modules/test_copy_callbacks/test_copy_callbacks.c b/src/test/modules/test_copy_callbacks/test_copy_callbacks.c index 0bbd2aa6bb..b465fd1dca 100644 --- a/src/test/modules/test_copy_callbacks/test_copy_callbacks.c +++ b/src/test/modules/test_copy_callbacks/test_copy_callbacks.c @@ -14,6 +14,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/table.h" #include "commands/copy.h" #include "fmgr.h" diff --git a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c index 85038f549d..94308c9a30 100644 --- a/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c +++ b/src/test/modules/test_custom_rmgrs/test_custom_rmgrs.c @@ -17,6 +17,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/xlog.h" #include "access/xlog_internal.h" #include "access/xloginsert.h" diff --git a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c index 67ff2b6367..544b498dc6 100644 --- a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c +++ b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c @@ -10,6 +10,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_type.h" #include "funcapi.h" #include "nodes/execnodes.h" diff --git a/src/test/modules/test_dsa/test_dsa.c b/src/test/modules/test_dsa/test_dsa.c index c78af68f61..2142396c74 100644 --- a/src/test/modules/test_dsa/test_dsa.c +++ b/src/test/modules/test_dsa/test_dsa.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "storage/lwlock.h" #include "utils/dsa.h" diff --git a/src/test/modules/test_dsm_registry/test_dsm_registry.c b/src/test/modules/test_dsm_registry/test_dsm_registry.c index 96eaa850bf..e05ffdbcd7 100644 --- a/src/test/modules/test_dsm_registry/test_dsm_registry.c +++ b/src/test/modules/test_dsm_registry/test_dsm_registry.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "storage/dsm_registry.h" #include "storage/lwlock.h" diff --git a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c index 04215cadd9..24f5a1009d 100644 --- a/src/test/modules/test_ginpostinglist/test_ginpostinglist.c +++ b/src/test/modules/test_ginpostinglist/test_ginpostinglist.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/gin_private.h" #include "access/ginblock.h" #include "access/htup_details.h" diff --git a/src/test/modules/test_integerset/test_integerset.c b/src/test/modules/test_integerset/test_integerset.c index 61f8d0b663..0331c40ba2 100644 --- a/src/test/modules/test_integerset/test_integerset.c +++ b/src/test/modules/test_integerset/test_integerset.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "common/pg_prng.h" #include "fmgr.h" #include "lib/integerset.h" diff --git a/src/test/modules/test_lfind/test_lfind.c b/src/test/modules/test_lfind/test_lfind.c index c04bc2f6b4..92266e644f 100644 --- a/src/test/modules/test_lfind/test_lfind.c +++ b/src/test/modules/test_lfind/test_lfind.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "port/pg_lfind.h" diff --git a/src/test/modules/test_oat_hooks/test_oat_hooks.c b/src/test/modules/test_oat_hooks/test_oat_hooks.c index 05c3371225..8834a9f215 100644 --- a/src/test/modules/test_oat_hooks/test_oat_hooks.c +++ b/src/test/modules/test_oat_hooks/test_oat_hooks.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/parallel.h" #include "catalog/dependency.h" #include "catalog/objectaccess.h" diff --git a/src/test/modules/test_parser/test_parser.c b/src/test/modules/test_parser/test_parser.c index f3de7d8abf..dedfb11187 100644 --- a/src/test/modules/test_parser/test_parser.c +++ b/src/test/modules/test_parser/test_parser.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" PG_MODULE_MAGIC; diff --git a/src/test/modules/test_predtest/test_predtest.c b/src/test/modules/test_predtest/test_predtest.c index eaf006c649..4beef8fa49 100644 --- a/src/test/modules/test_predtest/test_predtest.c +++ b/src/test/modules/test_predtest/test_predtest.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/htup_details.h" #include "catalog/pg_type.h" #include "executor/spi.h" diff --git a/src/test/modules/test_radixtree/test_radixtree.c b/src/test/modules/test_radixtree/test_radixtree.c index 1d9165a3a2..3e79bf14ab 100644 --- a/src/test/modules/test_radixtree/test_radixtree.c +++ b/src/test/modules/test_radixtree/test_radixtree.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "common/int.h" #include "common/pg_prng.h" #include "fmgr.h" diff --git a/src/test/modules/test_rbtree/test_rbtree.c b/src/test/modules/test_rbtree/test_rbtree.c index 3e76d27bf1..8234724bb5 100644 --- a/src/test/modules/test_rbtree/test_rbtree.c +++ b/src/test/modules/test_rbtree/test_rbtree.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "common/pg_prng.h" #include "fmgr.h" #include "lib/rbtree.h" diff --git a/src/test/modules/test_regex/test_regex.c b/src/test/modules/test_regex/test_regex.c index c4ef15d742..5ce8d1b30a 100644 --- a/src/test/modules/test_regex/test_regex.c +++ b/src/test/modules/test_regex/test_regex.c @@ -14,6 +14,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "funcapi.h" #include "miscadmin.h" #include "regex/regex.h" diff --git a/src/test/modules/test_resowner/test_resowner_basic.c b/src/test/modules/test_resowner/test_resowner_basic.c index 558cf1de56..664cfa8ffc 100644 --- a/src/test/modules/test_resowner/test_resowner_basic.c +++ b/src/test/modules/test_resowner/test_resowner_basic.c @@ -12,6 +12,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "lib/ilist.h" #include "utils/memutils.h" diff --git a/src/test/modules/test_rls_hooks/test_rls_hooks.c b/src/test/modules/test_rls_hooks/test_rls_hooks.c index 358e28edb4..c123731941 100644 --- a/src/test/modules/test_rls_hooks/test_rls_hooks.c +++ b/src/test/modules/test_rls_hooks/test_rls_hooks.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "catalog/pg_type.h" #include "fmgr.h" #include "miscadmin.h" diff --git a/src/test/modules/test_shm_mq/test.c b/src/test/modules/test_shm_mq/test.c index 3d235568b8..591b7dcebd 100644 --- a/src/test/modules/test_shm_mq/test.c +++ b/src/test/modules/test_shm_mq/test.c @@ -13,6 +13,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "fmgr.h" #include "miscadmin.h" #include "pgstat.h" diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c index d227b06703..e73a11e202 100644 --- a/src/test/modules/test_slru/test_slru.c +++ b/src/test/modules/test_slru/test_slru.c @@ -14,6 +14,8 @@ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/slru.h" #include "access/transam.h" #include "miscadmin.h" diff --git a/src/test/modules/test_tidstore/test_tidstore.c b/src/test/modules/test_tidstore/test_tidstore.c index 5417163407..2a8db7cf39 100644 --- a/src/test/modules/test_tidstore/test_tidstore.c +++ b/src/test/modules/test_tidstore/test_tidstore.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/tidstore.h" #include "fmgr.h" #include "funcapi.h" diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c index 7e1042f4ab..68d6b6c6f4 100644 --- a/src/test/modules/worker_spi/worker_spi.c +++ b/src/test/modules/worker_spi/worker_spi.c @@ -22,6 +22,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + /* These are always necessary for a bgworker */ #include "miscadmin.h" #include "postmaster/bgworker.h" diff --git a/src/test/modules/xid_wraparound/xid_wraparound.c b/src/test/modules/xid_wraparound/xid_wraparound.c index dce81c0c6d..740a39df5c 100644 --- a/src/test/modules/xid_wraparound/xid_wraparound.c +++ b/src/test/modules/xid_wraparound/xid_wraparound.c @@ -14,6 +14,8 @@ */ #include "postgres.h" +#define PG_THREADSAFE_EXTENSION 1 + #include "access/xact.h" #include "miscadmin.h" #include "storage/proc.h" diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index deffaea578..9bbe88cabb 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -19,6 +19,8 @@ #include <math.h> #include <signal.h> +#define PG_THREADSAFE_EXTENSION 1 + #include "access/detoast.h" #include "access/htup_details.h" #include "access/transam.h" -- 2.39.3 (Apple Git-145) ^ permalink raw reply [nested|flat] 97+ messages in thread
end of thread, other threads:[~2024-06-05 20:05 UTC | newest] Thread overview: 97+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2021-03-04 23:16 [PATCH 1/8] introduce bsearch_arg Tomas Vondra <[email protected]> 2024-06-05 20:05 [multithreading] extension compatibility Robert Haas <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox