public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 1/5] bootstrap: convert Typ to a List*
6+ messages / 4 participants
[nested] [flat]

* [PATCH 1/5] bootstrap: convert Typ to a List*
@ 2020-11-20 02:48  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Justin Pryzby @ 2020-11-20 02:48 UTC (permalink / raw)

---
 src/backend/bootstrap/bootstrap.c | 69 ++++++++++++++-----------------
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 6f615e6622..18eb62ca47 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -159,7 +159,7 @@ struct typmap
 	FormData_pg_type am_typ;
 };
 
-static struct typmap **Typ = NULL;
+static List *Typ = NIL; /* List of struct typmap* */
 static struct typmap *Ap = NULL;
 
 static Datum values[MAXATTR];	/* current row's attribute values */
@@ -597,7 +597,7 @@ boot_openrel(char *relname)
 	 * pg_type must be filled before any OPEN command is executed, hence we
 	 * can now populate the Typ array if we haven't yet.
 	 */
-	if (Typ == NULL)
+	if (Typ == NIL)
 		populate_typ_array();
 
 	if (boot_reldesc != NULL)
@@ -688,7 +688,7 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
 
 	typeoid = gettype(type);
 
-	if (Typ != NULL)
+	if (Typ != NIL)
 	{
 		attrtypes[attnum]->atttypid = Ap->am_oid;
 		attrtypes[attnum]->attlen = Ap->am_typ.typlen;
@@ -877,36 +877,25 @@ populate_typ_array(void)
 	Relation	rel;
 	TableScanDesc scan;
 	HeapTuple	tup;
-	int			nalloc;
-	int			i;
-
-	Assert(Typ == NULL);
 
-	nalloc = 512;
-	Typ = (struct typmap **)
-		MemoryContextAlloc(TopMemoryContext, nalloc * sizeof(struct typmap *));
+	Assert(Typ == NIL);
 
 	rel = table_open(TypeRelationId, NoLock);
 	scan = table_beginscan_catalog(rel, 0, NULL);
-	i = 0;
 	while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
 	{
 		Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup);
+		struct typmap *newtyp;
+		MemoryContext old;
 
-		/* make sure there will be room for a trailing NULL pointer */
-		if (i >= nalloc - 1)
-		{
-			nalloc *= 2;
-			Typ = (struct typmap **)
-				repalloc(Typ, nalloc * sizeof(struct typmap *));
-		}
-		Typ[i] = (struct typmap *)
-			MemoryContextAlloc(TopMemoryContext, sizeof(struct typmap));
-		Typ[i]->am_oid = typForm->oid;
-		memcpy(&(Typ[i]->am_typ), typForm, sizeof(Typ[i]->am_typ));
-		i++;
+		old = MemoryContextSwitchTo(TopMemoryContext);
+		newtyp = (struct typmap *) palloc(sizeof(struct typmap));
+		Typ = lappend(Typ, newtyp);
+		MemoryContextSwitchTo(old);
+
+		newtyp->am_oid = typForm->oid;
+		memcpy(&newtyp->am_typ, typForm, sizeof(newtyp->am_typ));
 	}
-	Typ[i] = NULL;				/* Fill trailing NULL pointer */
 	table_endscan(scan);
 	table_close(rel, NoLock);
 }
@@ -925,16 +914,17 @@ populate_typ_array(void)
 static Oid
 gettype(char *type)
 {
-	if (Typ != NULL)
+	if (Typ != NIL)
 	{
-		struct typmap **app;
+		ListCell *lc;
 
-		for (app = Typ; *app != NULL; app++)
+		foreach (lc, Typ)
 		{
-			if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
+			struct typmap *app = lfirst(lc);
+			if (strncmp(NameStr(app->am_typ.typname), type, NAMEDATALEN) == 0)
 			{
-				Ap = *app;
-				return (*app)->am_oid;
+				Ap = app;
+				return app->am_oid;
 			}
 		}
 	}
@@ -980,14 +970,17 @@ boot_get_type_io_data(Oid typid,
 	if (Typ != NULL)
 	{
 		/* We have the boot-time contents of pg_type, so use it */
-		struct typmap **app;
-		struct typmap *ap;
-
-		app = Typ;
-		while (*app && (*app)->am_oid != typid)
-			++app;
-		ap = *app;
-		if (ap == NULL)
+		struct typmap *ap = NULL;
+		ListCell *lc;
+
+		foreach (lc, Typ)
+		{
+			ap = lfirst(lc);
+			if (ap->am_oid == typid)
+				break;
+		}
+
+		if (!ap || ap->am_oid != typid)
 			elog(ERROR, "type OID %u not found in Typ list", typid);
 
 		*typlen = ap->am_typ.typlen;
-- 
2.26.2


--------------614DDB87AFFED893713AC0E9
Content-Type: text/x-patch; charset=UTF-8;
 name="0002-Allow-composite-types-in-bootstrap-20210304.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0002-Allow-composite-types-in-bootstrap-20210304.patch"



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

* Re: win32ver data in meson-built postgres.exe
@ 2023-06-07 23:47  Andres Freund <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Andres Freund @ 2023-06-07 23:47 UTC (permalink / raw)
  To: Noah Misch <[email protected]>; +Cc: pgsql-hackers

Hi,

On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> A postgres.exe built with meson, ninja, and MSVC lacks the version metadata
> that postgres.exe gets under non-meson build systems.  Patch attached.

I dimly recall that we discussed that and basically decided that it doesn't
really make sense to attach this information to postgres.exe.


>     This preserves two quirks of the older build systems.  First,
>     postgres.exe is icon-free.

We could also just change that.


>     Second, the resources object is not an input
>     to postgres.def.

I don't see what negative effects that could have: postgres.def is used to
provide symbol "thunks" to extension libraries, which don't need to access
this information.  If we used the rc compiler to inject binary data (say
bootstrap.bki) into binaries, it'd possibly be a different story (although I
think it might work anyway) - but if we wanted to do something like that, we'd
build portable infrastructure anyway.


> -  rcgen_bin_args = rcgen_base_args + [
> +  rcgen_server_args = rcgen_base_args + [
>      '--VFT_TYPE', 'VFT_APP',
> -    '--FILEENDING', 'exe',
> +    '--FILEENDING', 'exe'
> +  ]
> +
> +  rcgen_bin_args = rcgen_server_args + [
>      '--ICO', pg_ico
>    ]

Somehow it seems a bit wrong to derive non-server from server, but ... ;)


Greetings,

Andres Freund






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

* Re: win32ver data in meson-built postgres.exe
@ 2023-06-08 01:45  Noah Misch <[email protected]>
  parent: Andres Freund <[email protected]>
  0 siblings, 2 replies; 6+ messages in thread

From: Noah Misch @ 2023-06-08 01:45 UTC (permalink / raw)
  To: Andres Freund <[email protected]>; +Cc: pgsql-hackers

On Wed, Jun 07, 2023 at 04:47:26PM -0700, Andres Freund wrote:
> On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> > A postgres.exe built with meson, ninja, and MSVC lacks the version metadata
> > that postgres.exe gets under non-meson build systems.  Patch attached.
> 
> I dimly recall that we discussed that and basically decided that it doesn't
> really make sense to attach this information to postgres.exe.

I looked for a discussion behind that, but I didn't find it.  A key
user-visible consequence is whether the task manager "Name" column shows (1)
"PostgreSQL Server" (version data present) vs. (2) "postgres.exe" (no version
data).  While (2) is not terrible, (1) is more typical on Windows.  I don't
see cause to migrate to (2) after N years of sending (1).  Certainly this part
of the user experience should not depend on one's choice of build system.

> >     This preserves two quirks of the older build systems.  First,
> >     postgres.exe is icon-free.
> 
> We could also just change that.

I would be +1 for that (only if done for all build systems).  Showing the
elephant in task manager feels better than showing the generic-exe icon.

> >     Second, the resources object is not an input
> >     to postgres.def.
> 
> I don't see what negative effects that could have:

Agreed.  I wrote that sentence for archaeologists of the future who might
wonder why this change didn't use generated_backend_sources.






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

* Re: win32ver data in meson-built postgres.exe
@ 2023-06-08 11:10  Magnus Hagander <[email protected]>
  parent: Noah Misch <[email protected]>
  1 sibling, 1 reply; 6+ messages in thread

From: Magnus Hagander @ 2023-06-08 11:10 UTC (permalink / raw)
  To: Noah Misch <[email protected]>; +Cc: Andres Freund <[email protected]>; pgsql-hackers

On Thu, Jun 8, 2023 at 3:45 AM Noah Misch <[email protected]> wrote:
>
> On Wed, Jun 07, 2023 at 04:47:26PM -0700, Andres Freund wrote:
> > On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> > > A postgres.exe built with meson, ninja, and MSVC lacks the version metadata
> > > that postgres.exe gets under non-meson build systems.  Patch attached.
> >
> > I dimly recall that we discussed that and basically decided that it doesn't
> > really make sense to attach this information to postgres.exe.
>
> I looked for a discussion behind that, but I didn't find it.  A key
> user-visible consequence is whether the task manager "Name" column shows (1)
> "PostgreSQL Server" (version data present) vs. (2) "postgres.exe" (no version
> data).  While (2) is not terrible, (1) is more typical on Windows.  I don't
> see cause to migrate to (2) after N years of sending (1).  Certainly this part
> of the user experience should not depend on one's choice of build system.

+1, both on that it should be the same across build systems, and that
the variant that we have in the msvc build system is the best one.

And if we don't have the version structure in it, it will cause issues
for installers (I think) and software inventory processes (definitely)
that also use that.

I don't recall a discussion about removing it, but it's not unlikely I
missed it if it did take place...


> > >     This preserves two quirks of the older build systems.  First,
> > >     postgres.exe is icon-free.
> >
> > We could also just change that.
>
> I would be +1 for that (only if done for all build systems).  Showing the
> elephant in task manager feels better than showing the generic-exe icon.

I think this decision goes back all the way to the ancient times, and
the argument was then "user should not use the postgres.exe file when
clicking around" sort of. Back then, task manager didn't show the icon
at all, regardless. It does now, so I'm +1 to add the icon (in all the
build systems).

-- 
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/






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

* Re: win32ver data in meson-built postgres.exe
@ 2023-06-09 17:45  Andres Freund <[email protected]>
  parent: Noah Misch <[email protected]>
  1 sibling, 0 replies; 6+ messages in thread

From: Andres Freund @ 2023-06-09 17:45 UTC (permalink / raw)
  To: Noah Misch <[email protected]>; +Cc: pgsql-hackers

Hi,

On 2023-06-07 18:45:07 -0700, Noah Misch wrote:
> On Wed, Jun 07, 2023 at 04:47:26PM -0700, Andres Freund wrote:
> > On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> > > A postgres.exe built with meson, ninja, and MSVC lacks the version metadata
> > > that postgres.exe gets under non-meson build systems.  Patch attached.
> >
> > I dimly recall that we discussed that and basically decided that it doesn't
> > really make sense to attach this information to postgres.exe.
>
> I looked for a discussion behind that, but I didn't find it.  A key
> user-visible consequence is whether the task manager "Name" column shows (1)
> "PostgreSQL Server" (version data present) vs. (2) "postgres.exe" (no version
> data).  While (2) is not terrible, (1) is more typical on Windows.  I don't
> see cause to migrate to (2) after N years of sending (1).  Certainly this part
> of the user experience should not depend on one's choice of build system.

I think I misremembered some details... I guess I was remembering the icon for
dlls, in
https://postgr.es/m/20220829221314.pepagj3i5mj43niy%40awork3.anarazel.de

Touching the rc stuff always makes me feel dirty enough that I want to swap it
out of my brain, if not run some deep erase tool :)


> > >     This preserves two quirks of the older build systems.  First,
> > >     postgres.exe is icon-free.
> >
> > We could also just change that.
>
> I would be +1 for that (only if done for all build systems).  Showing the
> elephant in task manager feels better than showing the generic-exe icon.

Let's do that then.

Greetings,

Andres Freund






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

* Re: win32ver data in meson-built postgres.exe
@ 2023-06-09 20:14  Noah Misch <[email protected]>
  parent: Magnus Hagander <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Noah Misch @ 2023-06-09 20:14 UTC (permalink / raw)
  To: Andres Freund <[email protected]>; Magnus Hagander <[email protected]>; +Cc: pgsql-hackers

On Thu, Jun 08, 2023 at 01:10:00PM +0200, Magnus Hagander wrote:
> On Thu, Jun 8, 2023 at 3:45 AM Noah Misch <[email protected]> wrote:
> > On Wed, Jun 07, 2023 at 04:47:26PM -0700, Andres Freund wrote:
> > > On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> > > >     postgres.exe is icon-free.
> > >
> > > We could also just change that.
> >
> > I would be +1 for that (only if done for all build systems).  Showing the
> > elephant in task manager feels better than showing the generic-exe icon.
> 
> I think this decision goes back all the way to the ancient times, and
> the argument was then "user should not use the postgres.exe file when
> clicking around" sort of. Back then, task manager didn't show the icon
> at all, regardless. It does now, so I'm +1 to add the icon (in all the
> build systems).

That sounds good, and it's the attached one-byte change.  That also simplifies
the Meson fix; new version attached.

Author:     Noah Misch <[email protected]>
Commit:     Noah Misch <[email protected]>

    Give postgres.exe the icon of other executables.
    
    We had left it icon-free since users won't achieve much by opening it
    from Windows Explorer.  Subsequent to that decision, Task Manager
    started to show the icon.  That shifts the balance in favor of attaching
    the icon, so do so.  No back-patch, but make this late addition to v16.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/Makefile b/src/backend/Makefile
index e4bf0fe..3c42003 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -10,8 +10,7 @@
 #-------------------------------------------------------------------------
 
 PGFILEDESC = "PostgreSQL Server"
-# This is a daemon process, which is why it is not labeled as an executable
-#PGAPPICON=win32
+PGAPPICON=win32
 
 subdir = src/backend
 top_builddir = ../..

Author:     Noah Misch <[email protected]>
Commit:     Noah Misch <[email protected]>

    Add win32ver data to meson-built postgres.exe.
    
    As in the older build systems, the resources object is not an input to
    postgres.def.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/meson.build b/src/backend/meson.build
index ccfc382..88a35e9 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -5,6 +5,7 @@ backend_sources = []
 backend_link_with = [pgport_srv, common_srv]
 
 generated_backend_sources = []
+post_export_backend_sources = []
 
 subdir('access')
 subdir('archive')
@@ -133,8 +134,15 @@ if dtrace.found() and host_system != 'darwin'
   )
 endif
 
+if host_system == 'windows'
+  post_export_backend_sources += rc_bin_gen.process(win32ver_rc, extra_args: [
+    '--NAME', 'postgres',
+    '--FILEDESC', 'PostgreSQL Server',])
+endif
+
 postgres = executable('postgres',
   backend_input,
+  sources: post_export_backend_sources,
   objects: backend_objs,
   link_args: backend_link_args,
   link_with: backend_link_with,


Attachments:

  [text/plain] icon-postgres.exe-v1.patch (947B, ../../[email protected]/2-icon-postgres.exe-v1.patch)
  download | inline diff:
Author:     Noah Misch <[email protected]>
Commit:     Noah Misch <[email protected]>

    Give postgres.exe the icon of other executables.
    
    We had left it icon-free since users won't achieve much by opening it
    from Windows Explorer.  Subsequent to that decision, Task Manager
    started to show the icon.  That shifts the balance in favor of attaching
    the icon, so do so.  No back-patch, but make this late addition to v16.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/Makefile b/src/backend/Makefile
index e4bf0fe..3c42003 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -10,8 +10,7 @@
 #-------------------------------------------------------------------------
 
 PGFILEDESC = "PostgreSQL Server"
-# This is a daemon process, which is why it is not labeled as an executable
-#PGAPPICON=win32
+PGAPPICON=win32
 
 subdir = src/backend
 top_builddir = ../..


  [text/plain] win32ver-backend-meson-v2.patch (1.1K, ../../[email protected]/3-win32ver-backend-meson-v2.patch)
  download | inline diff:
Author:     Noah Misch <[email protected]>
Commit:     Noah Misch <[email protected]>

    Add win32ver data to meson-built postgres.exe.
    
    As in the older build systems, the resources object is not an input to
    postgres.def.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/meson.build b/src/backend/meson.build
index ccfc382..88a35e9 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -5,6 +5,7 @@ backend_sources = []
 backend_link_with = [pgport_srv, common_srv]
 
 generated_backend_sources = []
+post_export_backend_sources = []
 
 subdir('access')
 subdir('archive')
@@ -133,8 +134,15 @@ if dtrace.found() and host_system != 'darwin'
   )
 endif
 
+if host_system == 'windows'
+  post_export_backend_sources += rc_bin_gen.process(win32ver_rc, extra_args: [
+    '--NAME', 'postgres',
+    '--FILEDESC', 'PostgreSQL Server',])
+endif
+
 postgres = executable('postgres',
   backend_input,
+  sources: post_export_backend_sources,
   objects: backend_objs,
   link_args: backend_link_args,
   link_with: backend_link_with,


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


end of thread, other threads:[~2023-06-09 20:14 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 02:48 [PATCH 1/5] bootstrap: convert Typ to a List* Justin Pryzby <[email protected]>
2023-06-07 23:47 Re: win32ver data in meson-built postgres.exe Andres Freund <[email protected]>
2023-06-08 01:45 ` Re: win32ver data in meson-built postgres.exe Noah Misch <[email protected]>
2023-06-08 11:10   ` Re: win32ver data in meson-built postgres.exe Magnus Hagander <[email protected]>
2023-06-09 20:14     ` Re: win32ver data in meson-built postgres.exe Noah Misch <[email protected]>
2023-06-09 17:45   ` Re: win32ver data in meson-built postgres.exe Andres Freund <[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