public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v3 2/4] make binaryheap available to frontend
9+ messages / 6 participants
[nested] [flat]

* [PATCH v3 2/4] make binaryheap available to frontend
@ 2023-07-22 22:04  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Nathan Bossart @ 2023-07-22 22:04 UTC (permalink / raw)

---
 src/backend/lib/Makefile                 |  1 -
 src/backend/lib/meson.build              |  1 -
 src/common/Makefile                      |  1 +
 src/{backend/lib => common}/binaryheap.c | 17 ++++++++++++++++-
 src/common/meson.build                   |  1 +
 5 files changed, 18 insertions(+), 3 deletions(-)
 rename src/{backend/lib => common}/binaryheap.c (96%)

diff --git a/src/backend/lib/Makefile b/src/backend/lib/Makefile
index 9dad31398a..b6cefd9cca 100644
--- a/src/backend/lib/Makefile
+++ b/src/backend/lib/Makefile
@@ -13,7 +13,6 @@ top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
 OBJS = \
-	binaryheap.o \
 	bipartite_match.o \
 	bloomfilter.o \
 	dshash.o \
diff --git a/src/backend/lib/meson.build b/src/backend/lib/meson.build
index 974cab8776..b4e88f54ae 100644
--- a/src/backend/lib/meson.build
+++ b/src/backend/lib/meson.build
@@ -1,7 +1,6 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
 backend_sources += files(
-  'binaryheap.c',
   'bipartite_match.c',
   'bloomfilter.c',
   'dshash.c',
diff --git a/src/common/Makefile b/src/common/Makefile
index 113029bf7b..cc5c54dcee 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -48,6 +48,7 @@ LIBS += $(PTHREAD_LIBS)
 OBJS_COMMON = \
 	archive.o \
 	base64.o \
+	binaryheap.o \
 	checksum_helper.o \
 	compression.o \
 	config_info.o \
diff --git a/src/backend/lib/binaryheap.c b/src/common/binaryheap.c
similarity index 96%
rename from src/backend/lib/binaryheap.c
rename to src/common/binaryheap.c
index 1737546757..f21838b946 100644
--- a/src/backend/lib/binaryheap.c
+++ b/src/common/binaryheap.c
@@ -6,15 +6,22 @@
  * Portions Copyright (c) 2012-2023, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *	  src/backend/lib/binaryheap.c
+ *	  src/common/binaryheap.c
  *
  *-------------------------------------------------------------------------
  */
 
+#ifdef FRONTEND
+#include "postgres_fe.h"
+#else
 #include "postgres.h"
+#endif
 
 #include <math.h>
 
+#ifdef FRONTEND
+#include "common/logging.h"
+#endif
 #include "lib/binaryheap.h"
 
 static void sift_down(binaryheap *heap, int node_off);
@@ -109,7 +116,11 @@ void
 binaryheap_add_unordered(binaryheap *heap, Datum d)
 {
 	if (heap->bh_size >= heap->bh_space)
+#ifdef FRONTEND
+		pg_fatal("out of binary heap slots");
+#else
 		elog(ERROR, "out of binary heap slots");
+#endif
 	heap->bh_has_heap_property = false;
 	heap->bh_nodes[heap->bh_size] = d;
 	heap->bh_size++;
@@ -141,7 +152,11 @@ void
 binaryheap_add(binaryheap *heap, Datum d)
 {
 	if (heap->bh_size >= heap->bh_space)
+#ifdef FRONTEND
+		pg_fatal("out of binary heap slots");
+#else
 		elog(ERROR, "out of binary heap slots");
+#endif
 	heap->bh_nodes[heap->bh_size] = d;
 	heap->bh_size++;
 	sift_up(heap, heap->bh_size - 1);
diff --git a/src/common/meson.build b/src/common/meson.build
index 53942a9a61..3b97497d1a 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -3,6 +3,7 @@
 common_sources = files(
   'archive.c',
   'base64.c',
+  'binaryheap.c',
   'checksum_helper.c',
   'compression.c',
   'controldata_utils.c',
-- 
2.25.1


--sdtB3X0nJg68CQEu
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0003-expand-binaryheap-api.patch"



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2024-12-23 12:14  Vladlen Popolitov <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Vladlen Popolitov @ 2024-12-23 12:14 UTC (permalink / raw)
  To: Heikki Linnakangas <[email protected]>; +Cc: Michael Paquier <[email protected]>; Andrew Kane <[email protected]>; Nathan Bossart <[email protected]>; Tom Lane <[email protected]>; pgsql-hackers

Heikki Linnakangas писал(а) 2024-12-23 14:05:
> On 23/12/2024 12:32, Vladlen Popolitov wrote:
>> I found the reason of this bug and the fix for it.
> 
> Cool!
> 
>> Fortunatelly meson has option to force put all object files to
>> library - add dependency with the flag link_whole .
>> 
>> I made the one-line patch and it fixes this issue.
>> 
>> -        'dependencies': opts['dependencies'] + [ssl],
>> +        'dependencies': opts['dependencies'] + [ssl] + 
>> [declare_dependency( link_whole  : cflag_libs)],
> 
> I'm no meson expert and don't have a Windows system to test on, but 
> this seems like a weird place to add the option. Could you do this 
> instead:
> 
> diff --git a/src/common/meson.build b/src/common/meson.build
> index 538e0f43d55..76a7f68fe30 100644
> --- a/src/common/meson.build
> +++ b/src/common/meson.build
> @@ -184,6 +184,7 @@ foreach name, opts : pgcommon_variants
> 
>    lib = static_library('libpgcommon@0@'.format(name),
>        link_with: cflag_libs,
> +      link_whole: cflag_libs,
>        c_pch: pch_c_h,
>        kwargs: opts + {
>          'include_directories': [

  Yes, it is also working option. I applied it and tested in the current 
master under Windows,
it works.

Attached patch changes this line in meson.build
>        link_with: cflag_libs,
> +      link_whole: cflag_libs,
>        c_pch: pch_c_h,



-- 
Best regards,

Vladlen Popolitov.


Attachments:

  [text/x-diff] v2-0001-Fix-meson.build-to-prevent-missed-obj-files-in-li.patch (757B, ../../[email protected]/2-v2-0001-Fix-meson.build-to-prevent-missed-obj-files-in-li.patch)
  download | inline diff:
From 06a1fe0c0d81974ebccbd2f031df62154bd1c29d Mon Sep 17 00:00:00 2001
From: Vladlen Popolitov <[email protected]>
Date: Mon, 23 Dec 2024 15:09:13 +0300
Subject: [PATCH v2] Fix meson.build to prevent missed obj files in lib under
 Windows

---
 src/common/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/common/meson.build b/src/common/meson.build
index 538e0f43d5..76a7f68fe3 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -184,6 +184,7 @@ foreach name, opts : pgcommon_variants
 
   lib = static_library('libpgcommon@0@'.format(name),
       link_with: cflag_libs,
+      link_whole: cflag_libs,
       c_pch: pch_c_h,
       kwargs: opts + {
         'include_directories': [
-- 
2.39.5 (Apple Git-154)



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2024-12-23 12:16  Vladlen Popolitov <[email protected]>
  parent: Vladlen Popolitov <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Vladlen Popolitov @ 2024-12-23 12:16 UTC (permalink / raw)
  To: Heikki Linnakangas <[email protected]>; +Cc: Michael Paquier <[email protected]>; Andrew Kane <[email protected]>; Nathan Bossart <[email protected]>; Tom Lane <[email protected]>; pgsql-hackers

Vladlen Popolitov писал(а) 2024-12-23 15:14:

>  Yes, it is also working option. I applied it and tested in the current 
> master under Windows,
> it works.
> 
> Attached patch changes this line in meson.build
>>        link_with: cflag_libs,
>> +      link_whole: cflag_libs,
>>        c_pch: pch_c_h,

I also created entry in the commit fest with this patch
https://commitfest.postgresql.org/51/5457/

-- 
Best regards,

Vladlen Popolitov.






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2024-12-25 16:19  Heikki Linnakangas <[email protected]>
  parent: Vladlen Popolitov <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Heikki Linnakangas @ 2024-12-25 16:19 UTC (permalink / raw)
  To: Vladlen Popolitov <[email protected]>; +Cc: Michael Paquier <[email protected]>; Andrew Kane <[email protected]>; Nathan Bossart <[email protected]>; Tom Lane <[email protected]>; pgsql-hackers

On 23/12/2024 14:16, Vladlen Popolitov wrote:
> Vladlen Popolitov писал(а) 2024-12-23 15:14:
> 
>>  Yes, it is also working option. I applied it and tested in the 
>> current master under Windows,
>> it works.
>>
>> Attached patch changes this line in meson.build
>>>        link_with: cflag_libs,
>>> +      link_whole: cflag_libs,
>>>        c_pch: pch_c_h,
> 
> I also created entry in the commit fest with this patch
> https://commitfest.postgresql.org/51/5457/

Ok, committed that, thanks1

-- 
Heikki Linnakangas
Neon (https://neon.tech)







^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2024-12-25 16:34  Tom Lane <[email protected]>
  parent: Heikki Linnakangas <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-12-25 16:34 UTC (permalink / raw)
  To: Heikki Linnakangas <[email protected]>; +Cc: Vladlen Popolitov <[email protected]>; Michael Paquier <[email protected]>; Andrew Kane <[email protected]>; Nathan Bossart <[email protected]>; pgsql-hackers

Heikki Linnakangas <[email protected]> writes:
> Ok, committed that, thanks1

The question this patch brings to my mind is whether libpgport
doesn't need the same treatment.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2024-12-25 17:25  Heikki Linnakangas <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Heikki Linnakangas @ 2024-12-25 17:25 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Vladlen Popolitov <[email protected]>; Michael Paquier <[email protected]>; Andrew Kane <[email protected]>; Nathan Bossart <[email protected]>; pgsql-hackers

On 25/12/2024 18:34, Tom Lane wrote:
> Heikki Linnakangas <[email protected]> writes:
>> Ok, committed that, thanks1
> 
> The question this patch brings to my mind is whether libpgport
> doesn't need the same treatment.

Good point. Yes it does.

I tested that by adding a dummy call to COMP_CRC32C() in a test module, 
and letting cirrus CI build it:

[17:10:32.715] dummy_index_am.c.obj : error LNK2001: unresolved external 
symbol pg_comp_crc32c

Committed the same fix for libpqport.

-- 
Heikki Linnakangas
Neon (https://neon.tech)







^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2025-01-03 16:08  Regina Obe <[email protected]>
  parent: Heikki Linnakangas <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Regina Obe @ 2025-01-03 16:08 UTC (permalink / raw)
  To: [email protected]; +Cc: Vladlen Popolitov <[email protected]>

I tested this with a patched version of the EDB PG 17 installer that includes this patch and it fixed the issue I was having described in:

https://www.postgresql.org/message-id/000001db1df8%2449765bb0%24dc631310%24%40pcorp.us

It would be great if this was backported to PG17.

The new status of this patch is: Needs review


^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2025-01-09 11:13  Vladlen Popolitov <[email protected]>
  parent: Regina Obe <[email protected]>
  0 siblings, 1 reply; 9+ messages in thread

From: Vladlen Popolitov @ 2025-01-09 11:13 UTC (permalink / raw)
  To: Regina Obe <[email protected]>; +Cc: [email protected]

Regina Obe писал(а) 2025-01-03 23:08:
> I tested this with a patched version of the EDB PG 17 installer that 
> includes this patch and it fixed the issue I was having described in:
> 
> https://www.postgresql.org/message-id/000001db1df8%2449765bb0%24dc631310%24%40pcorp.us
> 
> It would be great if this was backported to PG17.
> 
> The new status of this patch is: Needs review
Hi Regina,

As I see, this patch applied to master and immediately backported to 
PG16 and PG17 (changes
will appear in new versions, old versions are unchangeable). If this 
answered your question,
status should be returned to committed again.
-- 
Best regards,

Vladlen Popolitov.






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* RE: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows
@ 2025-01-09 16:35  Regina Obe <[email protected]>
  parent: Vladlen Popolitov <[email protected]>
  0 siblings, 0 replies; 9+ messages in thread

From: Regina Obe @ 2025-01-09 16:35 UTC (permalink / raw)
  To: 'Vladlen Popolitov' <[email protected]>; +Cc: [email protected]

> Regina Obe писал(а) 2025-01-03 23:08:
> > I tested this with a patched version of the EDB PG 17 installer that
> > includes this patch and it fixed the issue I was having described in:
> >
> > https://www.postgresql.org/message-
> id/000001db1df8%2449765bb0%24dc6313
> > 10%24%40pcorp.us
> >
> > It would be great if this was backported to PG17.
> >
> > The new status of this patch is: Needs review
> Hi Regina,
> 
> As I see, this patch applied to master and immediately backported to
> PG16 and PG17 (changes
> will appear in new versions, old versions are unchangeable). If this answered
> your question, status should be returned to committed again.
> --
> Best regards,
> 
> Vladlen Popolitov.

Apologies for my confusion.  I've flipped it back to committed.

Thanks,
Regina







^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2025-01-09 16:35 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-22 22:04 [PATCH v3 2/4] make binaryheap available to frontend Nathan Bossart <[email protected]>
2024-12-23 12:14 Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Vladlen Popolitov <[email protected]>
2024-12-23 12:16 ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Vladlen Popolitov <[email protected]>
2024-12-25 16:19   ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Heikki Linnakangas <[email protected]>
2024-12-25 16:34     ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Tom Lane <[email protected]>
2024-12-25 17:25       ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Heikki Linnakangas <[email protected]>
2025-01-03 16:08         ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Regina Obe <[email protected]>
2025-01-09 11:13           ` Re: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Vladlen Popolitov <[email protected]>
2025-01-09 16:35             ` RE: Exporting float_to_shortest_decimal_buf(n) with Postgres 17 on Windows Regina Obe <[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