pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedInconsistencies around defining FRONTEND
12+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2022-08-23 9352d5cf12 Don't define FRONTEND for ecpg libraries
2022-08-23 06e3559bad Don't define FRONTEND for initdb
2022-08-23 1d77afefbd Don't define FRONTEND for libpq
* Inconsistencies around defining FRONTEND
@ 2022-08-20 19:45 Andres Freund <andres@anarazel.de>
0 siblings, 2 replies; 12+ messages in thread
From: Andres Freund @ 2022-08-20 19:45 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; +Cc: pgsql-hackers@postgresql.org, samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
This started at https://postgr.es/m/20220817215317.poeofidf7o7dy6hy%40awork3.anarazel.de
Peter made a good point about -DFRONTED not being defined symmetrically
between meson and autoconf builds, which made me look at where we define
it. And I think we ought to clean this up independ of the meson patch.
On 2022-08-17 14:53:17 -0700, Andres Freund wrote:
> On 2022-08-17 15:50:23 +0200, Peter Eisentraut wrote:
> > - -DFRONTEND is used somewhat differently from the makefiles. For
> > example, meson sets -DFRONTEND for pg_controldata, but the
> > makefiles don't. Conversely, the makefiles set -DFRONTEND for
> > ecpglib, but meson does not. This should be checked again to make
> > sure it all matches up.
>
> Yes, should sync that up.
>
> FWIW, meson does add -DFRONTEND for ecpglib. There were a few places that did
> add it twice, I'll push a cleanup of that in a bit.
Yikes, the situation in HEAD is quite the mess.
Several .c files set FRONTEND themselves, so they can include postgres.h,
instead of postgres_fe.h:
$ git grep '#define.*FRONTEND' upstream/master ':^src/include/postgres_fe.h'
upstream/master:src/bin/pg_controldata/pg_controldata.c:#define FRONTEND 1
upstream/master:src/bin/pg_resetwal/pg_resetwal.c:#define FRONTEND 1
upstream/master:src/bin/pg_waldump/compat.c:#define FRONTEND 1
upstream/master:src/bin/pg_waldump/pg_waldump.c:#define FRONTEND 1
upstream/master:src/bin/pg_waldump/rmgrdesc.c:#define FRONTEND 1
Yet, most of them also define FRONTEND in both make and msvc buildsystem.
$ git grep -E "(D|AddDefine\(')FRONTEND" upstream/master src/bin/ src/tools/msvc/
upstream/master:src/bin/initdb/Makefile:override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
upstream/master:src/bin/pg_rewind/Makefile:override CPPFLAGS := -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS)
upstream/master:src/bin/pg_waldump/Makefile:override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libpgport->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libpgcommon->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libpgfeutils->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libpq->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $pgtypes->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libecpg->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $libecpgcompat->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $pgrewind->AddDefine('FRONTEND');
upstream/master:src/tools/msvc/Mkvcbuild.pm: $pg_waldump->AddDefine('FRONTEND')
That's largely because they also build files from src/backend, which obviously
contain no #define FRONTEND.
The -DFRONTENDs for the various ecpg libraries don't seem necessary
anymore. That looks to be a leftover from 7143b3e8213, before that ecpg had
copies of various pgport libraries.
Same with libpq, also looks to be obsoleted by 7143b3e8213.
I don't think we need FRONTEND in initdb - looks like that stopped being
required with af1a949109d.
Unfortunately, the remaining uses of FRONTEND are required. That's:
- pg_controldata, via #define
- pg_resetwal, via #define
- pg_rewind, via -DFRONTEND, due to xlogreader.c
- pg_waldump, via #define and -DFRONTEND, due to xlogreader.c, xlogstats.c, rmgrdesc/*desc.c
I'm kind of wondering if we should add xlogreader.c, xlogstat.c, *desc to
fe_utils, instead of building them in various places. That'd leave us only
with #define FRONTENDs for cases that do need to include postgres.h
themselves, which seems a lot more palatable.
Greetings,
Andres Freund
Attachments: download all (3 files, .tar.gz)
v1-0001-Don-t-define-FRONTEND-for-initdb.patch (text/x-diff, 3.1K) download
From 96b9580229956c95279b4546f52d781408a3b15b Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 20 Aug 2022 12:13:42 -0700
Subject: [PATCH v1 1/3] Don't define FRONTEND for initdb
No headers requiring FRONTED to be defined are included as of af1a949109d.
Since this is the last user of (frontend|contrib)_defines in Mkvcbuild.pm,
remove that. For commit the file should be perltidy'ed, but as that causes
more changes I thought it'd be easer like this for review.
---
src/bin/initdb/Makefile | 2 +-
src/tools/msvc/Mkvcbuild.pm | 14 ++------------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index b0dd13dfbdf..6737938c3f8 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -16,7 +16,7 @@ subdir = src/bin/initdb
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
-override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
+override CPPFLAGS := -I$(libpq_srcdir) -I$(top_srcdir)/src/timezone $(CPPFLAGS)
# Note: it's important that we link to encnames.o from libpgcommon, not
# from libpq, else we have risks of version skew if we run with a libpq
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index ee963d85f30..ac863418442 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -35,7 +35,6 @@ my $libpq;
my @unlink_on_exit;
# Set of variables for modules in contrib/ and src/test/modules/
-my $contrib_defines = {};
my @contrib_uselibpq = ();
my @contrib_uselibpgport = ();
my @contrib_uselibpgcommon = ();
@@ -53,7 +52,6 @@ my @contrib_excludes = (
'unsafe_tests');
# Set of variables for frontend modules
-my $frontend_defines = { 'initdb' => 'FRONTEND' };
my @frontend_uselibpq =
('pg_amcheck', 'pg_ctl', 'pg_upgrade', 'pgbench', 'psql', 'initdb');
my @frontend_uselibpgport = (
@@ -1126,7 +1124,7 @@ sub AdjustContribProj
{
my $proj = shift;
AdjustModule(
- $proj, $contrib_defines,
+ $proj,
\@contrib_uselibpq, \@contrib_uselibpgport,
\@contrib_uselibpgcommon, $contrib_extralibs,
$contrib_extrasource, $contrib_extraincludes);
@@ -1137,7 +1135,7 @@ sub AdjustFrontendProj
{
my $proj = shift;
AdjustModule(
- $proj, $frontend_defines,
+ $proj,
\@frontend_uselibpq, \@frontend_uselibpgport,
\@frontend_uselibpgcommon, $frontend_extralibs,
$frontend_extrasource, $frontend_extraincludes);
@@ -1147,7 +1145,6 @@ sub AdjustFrontendProj
sub AdjustModule
{
my $proj = shift;
- my $module_defines = shift;
my $module_uselibpq = shift;
my $module_uselibpgport = shift;
my $module_uselibpgcommon = shift;
@@ -1156,13 +1153,6 @@ sub AdjustModule
my $module_extraincludes = shift;
my $n = $proj->{name};
- if ($module_defines->{$n})
- {
- foreach my $d ($module_defines->{$n})
- {
- $proj->AddDefine($d);
- }
- }
if (grep { /^$n$/ } @{$module_uselibpq})
{
$proj->AddIncludeDir('src\interfaces\libpq');
--
2.37.0.3.g30cc8d0f14
v1-0002-Don-t-define-FRONTEND-for-ecpg-libraries.patch (text/x-diff, 3.3K) download
From f7a2ad801701a7eac8c1747de1a763558702ac2e Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 20 Aug 2022 12:16:47 -0700
Subject: [PATCH v1 2/3] Don't define FRONTEND for ecpg libraries
Looks like that's not needed after 7143b3e8213
---
src/interfaces/ecpg/compatlib/Makefile | 2 +-
src/interfaces/ecpg/ecpglib/Makefile | 2 +-
src/interfaces/ecpg/pgtypeslib/Makefile | 2 +-
src/tools/msvc/Mkvcbuild.pm | 3 ---
4 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index 867ad55539a..62b8a8c12cc 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -19,7 +19,7 @@ SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= $(MAJORVERSION)
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
- -I$(libpq_srcdir) -DFRONTEND $(CPPFLAGS)
+ -I$(libpq_srcdir) $(CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
SHLIB_LINK_INTERNAL = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq_pgport_shlib)
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index b00229f3fec..844fc6eb6ec 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -19,7 +19,7 @@ SO_MAJOR_VERSION= 6
SO_MINOR_VERSION= $(MAJORVERSION)
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
- -I$(libpq_srcdir) -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
+ -I$(libpq_srcdir) -I$(top_builddir)/src/port $(CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
OBJS = \
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index 763787f22da..13ef992ee72 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -19,7 +19,7 @@ SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= $(MAJORVERSION)
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
- -DFRONTEND $(CPPFLAGS)
+ $(CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
SHLIB_LINK_INTERNAL = -lpgcommon_shlib -lpgport_shlib
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index ac863418442..3a2dbdf267f 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -315,14 +315,12 @@ sub mkvcbuild
my $pgtypes = $solution->AddProject(
'libpgtypes', 'dll',
'interfaces', 'src/interfaces/ecpg/pgtypeslib');
- $pgtypes->AddDefine('FRONTEND');
$pgtypes->AddReference($libpgcommon, $libpgport);
$pgtypes->UseDef('src/interfaces/ecpg/pgtypeslib/pgtypeslib.def');
$pgtypes->AddIncludeDir('src/interfaces/ecpg/include');
my $libecpg = $solution->AddProject('libecpg', 'dll', 'interfaces',
'src/interfaces/ecpg/ecpglib');
- $libecpg->AddDefine('FRONTEND');
$libecpg->AddIncludeDir('src/interfaces/ecpg/include');
$libecpg->AddIncludeDir('src/interfaces/libpq');
$libecpg->AddIncludeDir('src/port');
@@ -333,7 +331,6 @@ sub mkvcbuild
my $libecpgcompat = $solution->AddProject(
'libecpg_compat', 'dll',
'interfaces', 'src/interfaces/ecpg/compatlib');
- $libecpgcompat->AddDefine('FRONTEND');
$libecpgcompat->AddIncludeDir('src/interfaces/ecpg/include');
$libecpgcompat->AddIncludeDir('src/interfaces/libpq');
$libecpgcompat->UseDef('src/interfaces/ecpg/compatlib/compatlib.def');
--
2.37.0.3.g30cc8d0f14
v1-0003-Don-t-define-FRONTEND-for-libpq.patch (text/x-diff, 1.4K) download
From 7c975742d1c7a991ed6fe404dad49f19e4256716 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 20 Aug 2022 12:21:53 -0700
Subject: [PATCH v1 3/3] Don't define FRONTEND for libpq
Looks like that's not needed after 7143b3e8213
---
src/interfaces/libpq/Makefile | 2 +-
src/tools/msvc/Mkvcbuild.pm | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 79c574eeb8b..1d31b256fc9 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -22,7 +22,7 @@ NAME= pq
SO_MAJOR_VERSION= 5
SO_MINOR_VERSION= $(MAJORVERSION)
-override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -I$(top_srcdir)/src/port
+override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -I$(top_srcdir)/src/port
ifneq ($(PORTNAME), win32)
override CFLAGS += $(PTHREAD_CFLAGS)
endif
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 3a2dbdf267f..5c4c0a98f13 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -263,7 +263,6 @@ sub mkvcbuild
$libpq = $solution->AddProject('libpq', 'dll', 'interfaces',
'src/interfaces/libpq');
- $libpq->AddDefine('FRONTEND');
$libpq->AddIncludeDir('src/port');
$libpq->AddLibrary('secur32.lib');
$libpq->AddLibrary('ws2_32.lib');
--
2.37.0.3.g30cc8d0f14
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-22 15:48 Andres Freund <andres@anarazel.de>
parent: Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 12+ messages in thread
From: Andres Freund @ 2022-08-22 15:48 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; +Cc: pgsql-hackers@postgresql.org, samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
On 2022-08-20 12:45:50 -0700, Andres Freund wrote:
> The -DFRONTENDs for the various ecpg libraries don't seem necessary
> anymore. That looks to be a leftover from 7143b3e8213, before that ecpg had
> copies of various pgport libraries.
>
> Same with libpq, also looks to be obsoleted by 7143b3e8213.
>
> I don't think we need FRONTEND in initdb - looks like that stopped being
> required with af1a949109d.
I think the patches for this are fairly obvious, and survived CI without an
issue [1], so the src/tools/msvc bits work too. So I'm planning to push them
fairly soon.
But the remaining "issues" don't have an obvious solutions and not addressed
by these patches:
> Unfortunately, the remaining uses of FRONTEND are required. That's:
> - pg_controldata, via #define
> - pg_resetwal, via #define
> - pg_rewind, via -DFRONTEND, due to xlogreader.c
> - pg_waldump, via #define and -DFRONTEND, due to xlogreader.c, xlogstats.c, rmgrdesc/*desc.c
>
> I'm kind of wondering if we should add xlogreader.c, xlogstat.c, *desc to
> fe_utils, instead of building them in various places. That'd leave us only
> with #define FRONTENDs for cases that do need to include postgres.h
> themselves, which seems a lot more palatable.
Greetings,
Andres Freund
[1] https://cirrus-ci.com/build/4648937721167872
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 03:42 Andres Freund <andres@anarazel.de>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 12+ messages in thread
From: Andres Freund @ 2022-08-23 03:42 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; +Cc: pgsql-hackers@postgresql.org, samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
On 2022-08-22 08:48:34 -0700, Andres Freund wrote:
> On 2022-08-20 12:45:50 -0700, Andres Freund wrote:
> > The -DFRONTENDs for the various ecpg libraries don't seem necessary
> > anymore. That looks to be a leftover from 7143b3e8213, before that ecpg had
> > copies of various pgport libraries.
> >
> > Same with libpq, also looks to be obsoleted by 7143b3e8213.
> >
> > I don't think we need FRONTEND in initdb - looks like that stopped being
> > required with af1a949109d.
>
> I think the patches for this are fairly obvious, and survived CI without an
> issue [1], so the src/tools/msvc bits work too. So I'm planning to push them
> fairly soon.
Done.
- Andres
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 21:24 Robert Haas <robertmhaas@gmail.com>
parent: Andres Freund <andres@anarazel.de>
1 sibling, 2 replies; 12+ messages in thread
From: Robert Haas @ 2022-08-23 21:24 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
On Sat, Aug 20, 2022 at 3:46 PM Andres Freund <andres@anarazel.de> wrote:
> Unfortunately, the remaining uses of FRONTEND are required. That's:
> - pg_controldata, via #define
> - pg_resetwal, via #define
> - pg_rewind, via -DFRONTEND, due to xlogreader.c
> - pg_waldump, via #define and -DFRONTEND, due to xlogreader.c, xlogstats.c, rmgrdesc/*desc.c
Actually, I think we could fix these pretty easily too. See attached.
This has been annoying me for a while. I hope we can agree on a way to
clean it up.
--
Robert Haas
EDB: http://www.enterprisedb.com
Attachments:
v1-0001-Remove-define-FRONTEND-hacks.patch (application/octet-stream, 17.9K) download
From a8030b0b30142fbbe709b72a00a12f14563b2189 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Tue, 23 Aug 2022 17:21:29 -0400
Subject: [PATCH v1] Remove '#define FRONTEND' hacks.
---
src/backend/replication/logical/proto.c | 1 +
src/bin/pg_controldata/pg_controldata.c | 9 +--------
src/bin/pg_resetwal/pg_resetwal.c | 9 +--------
src/bin/pg_waldump/compat.c | 4 +---
src/bin/pg_waldump/pg_waldump.c | 3 +--
src/bin/pg_waldump/rmgrdesc.c | 3 +--
src/include/access/brin_xlog.h | 1 -
src/include/access/generic_xlog.h | 7 +++++++
src/include/access/gist.h | 11 +++++++++++
src/include/access/heapam_xlog.h | 7 +++++++
src/include/access/heaptoast.h | 6 ++++++
src/include/access/htup_details.h | 3 ++-
src/include/access/itup.h | 3 ++-
src/include/access/xlog.h | 16 ++++++++++++----
src/include/access/xloginsert.h | 7 +++++++
src/include/catalog/objectaddress.h | 9 ++++++++-
src/include/catalog/pg_publication.h | 4 ++++
src/include/commands/sequence.h | 12 +++++++++---
src/include/commands/tablespace.h | 7 +++++++
src/include/storage/large_object.h | 4 ++++
src/include/utils/timestamp.h | 1 -
21 files changed, 92 insertions(+), 35 deletions(-)
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..48ebb046f7 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -15,6 +15,7 @@
#include "access/sysattr.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_type.h"
+#include "fmgr.h"
#include "libpq/pqformat.h"
#include "replication/logicalproto.h"
#include "utils/lsyscache.h"
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..9fa53d6a27 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -9,14 +9,7 @@
* src/bin/pg_controldata/pg_controldata.c
*/
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need. But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-
-#include "postgres.h"
+#include "postgres_fe.h"
#include <time.h>
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index d4772a2965..f93d816c21 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -28,14 +28,7 @@
*-------------------------------------------------------------------------
*/
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need. But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-
-#include "postgres.h"
+#include "postgres_fe.h"
#include <dirent.h>
#include <fcntl.h>
diff --git a/src/bin/pg_waldump/compat.c b/src/bin/pg_waldump/compat.c
index 6a3386e970..fe105c2bf9 100644
--- a/src/bin/pg_waldump/compat.c
+++ b/src/bin/pg_waldump/compat.c
@@ -14,9 +14,7 @@
*-------------------------------------------------------------------------
*/
-/* ugly hack, same as in e.g pg_controldata */
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
#include <time.h>
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 6528113628..f8bb2b6fef 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -9,8 +9,7 @@
*-------------------------------------------------------------------------
*/
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
#include <dirent.h>
#include <signal.h>
diff --git a/src/bin/pg_waldump/rmgrdesc.c b/src/bin/pg_waldump/rmgrdesc.c
index 6b8c17bb4c..1c20f29da1 100644
--- a/src/bin/pg_waldump/rmgrdesc.c
+++ b/src/bin/pg_waldump/rmgrdesc.c
@@ -5,8 +5,7 @@
*
* src/bin/pg_waldump/rmgrdesc.c
*/
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
#include "access/brin_xlog.h"
#include "access/clog.h"
diff --git a/src/include/access/brin_xlog.h b/src/include/access/brin_xlog.h
index 012a9afdf4..e27dc0eab0 100644
--- a/src/include/access/brin_xlog.h
+++ b/src/include/access/brin_xlog.h
@@ -19,7 +19,6 @@
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/relfilelocator.h"
-#include "utils/relcache.h"
/*
diff --git a/src/include/access/generic_xlog.h b/src/include/access/generic_xlog.h
index c8363a4766..21bdd3b38d 100644
--- a/src/include/access/generic_xlog.h
+++ b/src/include/access/generic_xlog.h
@@ -18,7 +18,10 @@
#include "access/xlog_internal.h"
#include "access/xloginsert.h"
#include "storage/bufpage.h"
+
+#ifndef FRONTEND
#include "utils/rel.h"
+#endif
#define MAX_GENERIC_XLOG_PAGES XLR_NORMAL_MAX_BLOCK_ID
@@ -29,6 +32,8 @@
struct GenericXLogState;
typedef struct GenericXLogState GenericXLogState;
+#ifndef FRONTEND
+
/* API for construction of generic xlog records */
extern GenericXLogState *GenericXLogStart(Relation relation);
extern Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer,
@@ -36,6 +41,8 @@ extern Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer,
extern XLogRecPtr GenericXLogFinish(GenericXLogState *state);
extern void GenericXLogAbort(GenericXLogState *state);
+#endif
+
/* functions defined for rmgr */
extern void generic_redo(XLogReaderState *record);
extern const char *generic_identify(uint8 info);
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index a3337627b8..3950b5d7d8 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -22,7 +22,10 @@
#include "access/xlogdefs.h"
#include "storage/block.h"
#include "storage/bufpage.h"
+
+#ifndef FRONTEND
#include "utils/relcache.h"
+#endif
/*
* amproc indexes for GiST indexes.
@@ -110,6 +113,8 @@ typedef GISTPageOpaqueData *GISTPageOpaque;
*/
#define GIST_PAGE_ID 0xFF81
+#ifndef FRONTEND
+
/*
* This is the Split Vector to be returned by the PickSplit method.
* PickSplit should fill the indexes of tuples to go to the left side into
@@ -164,6 +169,8 @@ typedef struct GISTENTRY
bool leafkey;
} GISTENTRY;
+#endif
+
#define GistPageGetOpaque(page) ( (GISTPageOpaque) PageGetSpecialPointer(page) )
#define GistPageIsLeaf(page) ( GistPageGetOpaque(page)->flags & F_LEAF)
@@ -226,6 +233,8 @@ GistPageGetDeleteXid(Page page)
return FullTransactionIdFromEpochAndXid(0, FirstNormalTransactionId);
}
+#ifndef FRONTEND
+
/*
* Vector of GISTENTRY structs; user-defined methods union and picksplit
* take it as one of their arguments
@@ -245,4 +254,6 @@ typedef struct
do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
(e).offset = (o); (e).leafkey = (l); } while (0)
+#endif
+
#endif /* GIST_H */
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index 1705e736be..7f89ec7edb 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -20,7 +20,10 @@
#include "storage/buf.h"
#include "storage/bufpage.h"
#include "storage/relfilelocator.h"
+
+#ifndef FRONTEND
#include "utils/relcache.h"
+#endif
/*
@@ -401,6 +404,8 @@ extern void heap2_desc(StringInfo buf, XLogReaderState *record);
extern const char *heap2_identify(uint8 info);
extern void heap_xlog_logical_rewrite(XLogReaderState *r);
+#ifndef FRONTEND
+
extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
TransactionId cutoff_xid, xl_heap_freeze_tuple *tuples,
int ntuples);
@@ -418,4 +423,6 @@ extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags);
+#endif
+
#endif /* HEAPAM_XLOG_H */
diff --git a/src/include/access/heaptoast.h b/src/include/access/heaptoast.h
index a75699054a..a5f8a8358b 100644
--- a/src/include/access/heaptoast.h
+++ b/src/include/access/heaptoast.h
@@ -15,7 +15,10 @@
#include "access/htup_details.h"
#include "storage/lockdefs.h"
+
+#ifndef FRONTEND
#include "utils/relcache.h"
+#endif
/*
* Find the maximum size of a tuple if there are to be N tuples per page.
@@ -88,6 +91,8 @@
sizeof(int32) - \
VARHDRSZ)
+#ifndef FRONTEND
+
/* ----------
* heap_toast_insert_or_update -
*
@@ -145,5 +150,6 @@ extern HeapTuple toast_build_flattened_tuple(TupleDesc tupleDesc,
extern void heap_fetch_toast_slice(Relation toastrel, Oid valueid,
int32 attrsize, int32 sliceoffset,
int32 slicelength, struct varlena *result);
+#endif
#endif /* HEAPTOAST_H */
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 51a60eda08..1ac148a37c 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -690,6 +690,8 @@ struct MinimalTupleData
#define HeapTupleClearHeapOnly(tuple) \
HeapTupleHeaderClearHeapOnly((tuple)->t_data)
+#ifndef FRONTEND
+
/* prototypes for functions in common/heaptuple.c */
extern Size heap_compute_data_size(TupleDesc tupleDesc,
Datum *values, bool *isnull);
@@ -733,7 +735,6 @@ extern size_t varsize_any(void *p);
extern HeapTuple heap_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleDesc);
extern MinimalTuple minimal_expand_tuple(HeapTuple sourceTuple, TupleDesc tupleDesc);
-#ifndef FRONTEND
/*
* fastgetattr
* Fetch a user attribute's value as a Datum (might be either a
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 773cef8b3a..014f1f5c46 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -74,6 +74,7 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
/* routines in indextuple.c */
+#ifndef FRONTEND
extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor,
Datum *values, bool *isnull);
extern IndexTuple index_form_tuple_context(TupleDesc tupleDescriptor,
@@ -89,7 +90,7 @@ extern void index_deform_tuple_internal(TupleDesc tupleDescriptor,
extern IndexTuple CopyIndexTuple(IndexTuple source);
extern IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor,
IndexTuple source, int leavenatts);
-
+#endif
/*
* Takes an infomask as argument (primarily because this needs to be usable
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index cd674c3c23..7e8d79eee0 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -192,6 +192,12 @@ typedef enum WALAvailability
struct XLogRecData;
+extern void xlog_desc(StringInfo buf, XLogReaderState *record);
+extern const char *xlog_identify(uint8 info);
+extern void xlog_redo(XLogReaderState *record);
+
+#ifndef FRONTEND
+
extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata,
XLogRecPtr fpw_lsn,
uint8 flags,
@@ -208,10 +214,6 @@ extern XLogSegNo XLogGetLastRemovedSegno(void);
extern void XLogSetAsyncXactLSN(XLogRecPtr record);
extern void XLogSetReplicationSlotMinimumLSN(XLogRecPtr lsn);
-extern void xlog_redo(XLogReaderState *record);
-extern void xlog_desc(StringInfo buf, XLogReaderState *record);
-extern const char *xlog_identify(uint8 info);
-
extern void issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli);
extern bool RecoveryInProgress(void);
@@ -259,6 +261,8 @@ extern void SetInstallXLogFileSegmentActive(void);
extern bool IsInstallXLogFileSegmentActive(void);
extern void XLogShutdownWalRcv(void);
+#endif
+
/*
* Routines to start, stop, and get status of a base backup.
*/
@@ -279,6 +283,8 @@ typedef enum SessionBackupState
SESSION_BACKUP_RUNNING,
} SessionBackupState;
+#ifndef FRONTEND
+
extern XLogRecPtr do_pg_backup_start(const char *backupidstr, bool fast,
TimeLineID *starttli_p, StringInfo labelfile,
List **tablespaces, StringInfo tblspcmapfile);
@@ -288,6 +294,8 @@ extern void do_pg_abort_backup(int code, Datum arg);
extern void register_persistent_abort_backup_handler(void);
extern SessionBackupState get_backup_status(void);
+#endif
+
/* File path names (all relative to $PGDATA) */
#define RECOVERY_SIGNAL_FILE "recovery.signal"
#define STANDBY_SIGNAL_FILE "standby.signal"
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index aed4643d1c..42bb275dd2 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -16,7 +16,10 @@
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/relfilelocator.h"
+
+#ifndef FRONTEND
#include "utils/relcache.h"
+#endif
/*
* The minimum size of the WAL construction working area. If you need to
@@ -38,6 +41,8 @@
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
+#ifndef FRONTEND
+
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
extern void XLogSetRecordFlags(uint8 flags);
@@ -63,4 +68,6 @@ extern XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std);
extern void InitXLogInsert(void);
+#endif
+
#endif /* XLOGINSERT_H */
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index cf4d8b3107..cc20a5f399 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -14,9 +14,12 @@
#define OBJECTADDRESS_H
#include "access/htup.h"
-#include "nodes/parsenodes.h"
#include "storage/lockdefs.h"
+
+#ifndef FRONTEND
+#include "nodes/parsenodes.h"
#include "utils/relcache.h"
+#endif
/*
* An ObjectAddress represents a database object of any type.
@@ -40,6 +43,8 @@ extern PGDLLIMPORT const ObjectAddress InvalidObjectAddress;
#define ObjectAddressSet(addr, class_id, object_id) \
ObjectAddressSubSet(addr, class_id, object_id, 0)
+#ifndef FRONTEND
+
extern ObjectAddress get_object_address(ObjectType objtype, Node *object,
Relation *relp,
LOCKMODE lockmode, bool missing_ok);
@@ -86,4 +91,6 @@ extern struct ArrayType *strlist_to_textarray(List *list);
extern ObjectType get_relkind_objtype(char relkind);
+#endif
+
#endif /* OBJECTADDRESS_H */
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index c298327f5e..6d29adb734 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -103,6 +103,8 @@ typedef struct Publication
PublicationActions pubactions;
} Publication;
+#ifndef FRONTEND
+
typedef struct PublicationRelInfo
{
Relation relation;
@@ -155,4 +157,6 @@ extern ObjectAddress publication_add_schema(Oid pubid, Oid schemaid,
extern Bitmapset *pub_collist_to_bitmapset(Bitmapset *columns, Datum pubcols,
MemoryContext mcxt);
+#endif
+
#endif /* PG_PUBLICATION_H */
diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h
index d38c0e2388..a5846b1e74 100644
--- a/src/include/commands/sequence.h
+++ b/src/include/commands/sequence.h
@@ -15,12 +15,14 @@
#include "access/xlogreader.h"
#include "catalog/objectaddress.h"
-#include "fmgr.h"
#include "lib/stringinfo.h"
-#include "nodes/parsenodes.h"
-#include "parser/parse_node.h"
#include "storage/relfilelocator.h"
+#ifndef FRONTEND
+#include "fmgr.h"
+#include "nodes/parsenodes.h"
+#include "parser/parse_node.h"
+#endif
typedef struct FormData_pg_sequence_data
{
@@ -51,6 +53,8 @@ typedef struct xl_seq_rec
/* SEQUENCE TUPLE DATA FOLLOWS AT THE END */
} xl_seq_rec;
+#ifndef FRONTEND
+
extern int64 nextval_internal(Oid relid, bool check_permissions);
extern Datum nextval(PG_FUNCTION_ARGS);
extern List *sequence_options(Oid relid);
@@ -62,6 +66,8 @@ extern void DeleteSequenceTuple(Oid relid);
extern void ResetSequence(Oid seq_relid);
extern void ResetSequenceCaches(void);
+#endif
+
extern void seq_redo(XLogReaderState *rptr);
extern void seq_desc(StringInfo buf, XLogReaderState *rptr);
extern const char *seq_identify(uint8 info);
diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h
index 1f80907112..9b7b1424e6 100644
--- a/src/include/commands/tablespace.h
+++ b/src/include/commands/tablespace.h
@@ -17,7 +17,10 @@
#include "access/xlogreader.h"
#include "catalog/objectaddress.h"
#include "lib/stringinfo.h"
+
+#ifndef FRONTEND
#include "nodes/parsenodes.h"
+#endif
extern PGDLLIMPORT bool allow_in_place_tablespaces;
@@ -45,6 +48,8 @@ typedef struct TableSpaceOpts
int maintenance_io_concurrency;
} TableSpaceOpts;
+#ifndef FRONTEND
+
extern Oid CreateTableSpace(CreateTableSpaceStmt *stmt);
extern void DropTableSpace(DropTableSpaceStmt *stmt);
extern ObjectAddress RenameTableSpace(const char *oldname, const char *newname);
@@ -62,6 +67,8 @@ extern char *get_tablespace_name(Oid spc_oid);
extern bool directory_is_empty(const char *path);
extern void remove_tablespace_symlink(const char *linkloc);
+#endif
+
extern void tblspc_redo(XLogReaderState *rptr);
extern void tblspc_desc(StringInfo buf, XLogReaderState *rptr);
extern const char *tblspc_identify(uint8 info);
diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h
index b826a7dcd5..4a14cd3ed2 100644
--- a/src/include/storage/large_object.h
+++ b/src/include/storage/large_object.h
@@ -76,6 +76,8 @@ typedef struct LargeObjectDesc
#define MAX_LARGE_OBJECT_SIZE ((int64) INT_MAX * LOBLKSIZE)
+#ifndef FRONTEND
+
/*
* GUC: backwards-compatibility flag to suppress LO permission checks
*/
@@ -97,4 +99,6 @@ extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
extern int inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes);
extern void inv_truncate(LargeObjectDesc *obj_desc, int64 len);
+#endif
+
#endif /* LARGE_OBJECT_H */
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index edf3a97318..2c353ee1d7 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -14,7 +14,6 @@
#define TIMESTAMP_H
#include "datatype/timestamp.h"
-#include "fmgr.h"
#include "pgtime.h"
--
2.24.3 (Apple Git-128)
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 21:56 Tom Lane <tgl@sss.pgh.pa.us>
parent: Robert Haas <robertmhaas@gmail.com>
1 sibling, 1 reply; 12+ messages in thread
From: Tom Lane @ 2022-08-23 21:56 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> Actually, I think we could fix these pretty easily too. See attached.
Hmm, do these headers still pass headerscheck/cpluspluscheck?
I might quibble a bit with the exact placement of the #ifndef FRONTEND
tests, but overall this looks pretty plausible.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 22:58 Robert Haas <robertmhaas@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 12+ messages in thread
From: Robert Haas @ 2022-08-23 22:58 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@anarazel.de>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
On Tue, Aug 23, 2022 at 5:56 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > Actually, I think we could fix these pretty easily too. See attached.
>
> Hmm, do these headers still pass headerscheck/cpluspluscheck?
I didn't check before sending the patch, but now I ran it locally, and
I did get failures from both, but they all seem to be unrelated.
Mainly, it's sad that I don't have Python.h, but I didn't configure
with python, so whatever.
> I might quibble a bit with the exact placement of the #ifndef FRONTEND
> tests, but overall this looks pretty plausible.
Yep, that's arguable. In particular, should the redo functions also be
protected by #ifdef FRONTEND?
I'd be more than thrilled if you wanted to adjust this to taste and
apply it, barring objections from others of course.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 23:24 Andres Freund <andres@anarazel.de>
parent: Robert Haas <robertmhaas@gmail.com>
1 sibling, 1 reply; 12+ messages in thread
From: Andres Freund @ 2022-08-23 23:24 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
On 2022-08-23 17:24:30 -0400, Robert Haas wrote:
> On Sat, Aug 20, 2022 at 3:46 PM Andres Freund <andres@anarazel.de> wrote:
> > Unfortunately, the remaining uses of FRONTEND are required. That's:
> > - pg_controldata, via #define
> > - pg_resetwal, via #define
> > - pg_rewind, via -DFRONTEND, due to xlogreader.c
> > - pg_waldump, via #define and -DFRONTEND, due to xlogreader.c, xlogstats.c, rmgrdesc/*desc.c
>
> Actually, I think we could fix these pretty easily too.
I just meant that they're not already obsolete ;)
> See attached.
Just to make sure I understand - you're just trying to get rid of the #define
frontends, not the -DFRONTENDs passed in from the Makefile? Because afaics we
still need those, correct?
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 23:37 Robert Haas <robertmhaas@gmail.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 12+ messages in thread
From: Robert Haas @ 2022-08-23 23:37 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
On Tue, Aug 23, 2022 at 7:24 PM Andres Freund <andres@anarazel.de> wrote:
> Just to make sure I understand - you're just trying to get rid of the #define
> frontends, not the -DFRONTENDs passed in from the Makefile? Because afaics we
> still need those, correct?
Oh, yeah, this only fixes the #define ones. But maybe fixing the other
ones with a similar approach would be possible?
I really don't see why we should tolerate having #define FRONTEND in
more than once place.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-23 23:50 Tom Lane <tgl@sss.pgh.pa.us>
parent: Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 12+ messages in thread
From: Tom Lane @ 2022-08-23 23:50 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Aug 23, 2022 at 7:24 PM Andres Freund <andres@anarazel.de> wrote:
>> Just to make sure I understand - you're just trying to get rid of the #define
>> frontends, not the -DFRONTENDs passed in from the Makefile? Because afaics we
>> still need those, correct?
> Oh, yeah, this only fixes the #define ones. But maybe fixing the other
> ones with a similar approach would be possible?
> I really don't see why we should tolerate having #define FRONTEND in
> more than once place.
src/port and src/common really need to do it like that (ie pass in
the -D switch) so that the identical source file can be built
both ways. Maybe we could get rid of -DFRONTEND in other places,
like pg_rewind and pg_waldump.
regards, tom lane
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-24 01:55 Andres Freund <andres@anarazel.de>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: Andres Freund @ 2022-08-24 01:55 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Robert Haas <robertmhaas@gmail.com>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
On 2022-08-23 19:50:00 -0400, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > On Tue, Aug 23, 2022 at 7:24 PM Andres Freund <andres@anarazel.de> wrote:
> >> Just to make sure I understand - you're just trying to get rid of the #define
> >> frontends, not the -DFRONTENDs passed in from the Makefile? Because afaics we
> >> still need those, correct?
>
> > Oh, yeah, this only fixes the #define ones. But maybe fixing the other
> > ones with a similar approach would be possible?
>
> > I really don't see why we should tolerate having #define FRONTEND in
> > more than once place.
>
> src/port and src/common really need to do it like that (ie pass in
> the -D switch) so that the identical source file can be built
> both ways. Maybe we could get rid of -DFRONTEND in other places,
> like pg_rewind and pg_waldump.
We could, if we make xlogreader.c and the rmgrdesc routines built as part of
src/common. I don't really see how otherwise.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-24 14:40 Robert Haas <robertmhaas@gmail.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 12+ messages in thread
From: Robert Haas @ 2022-08-24 14:40 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
On Tue, Aug 23, 2022 at 9:55 PM Andres Freund <andres@anarazel.de> wrote:
> We could, if we make xlogreader.c and the rmgrdesc routines built as part of
> src/common. I don't really see how otherwise.
After a little bit of study, I agree.
It looks to me like -DFRONTEND can be removed from
src/fe_utils/Makefile and probably also src/common/unicode/Makefile
without changing anything else, because the C files in those
directories seem to be frontend-only and they already include
"postgres_fe.h". I think we should go ahead and do that, and also
apply the patch I posted yesterday with whatever bikeshedding seems
appropriate.
It doesn't really seem like we have a plausible alternative to the
current system for src/common or src/port.
pg_rewind and pg_waldump seem to need the xlogreader code moved to
src/common, as Andres proposes. I'm not volunteering to tackle that
right now but I think it might be a good thing to do sometime.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Inconsistencies around defining FRONTEND
@ 2022-08-24 15:10 Andres Freund <andres@anarazel.de>
parent: Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 12+ messages in thread
From: Andres Freund @ 2022-08-24 15:10 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Noah Misch <noah@leadboat.com>; pgsql-hackers; samay sharma <smilingsamay@gmail.com>; Nazir Bilal Yavuz <byavuz81@gmail.com>
Hi,
On 2022-08-24 10:40:01 -0400, Robert Haas wrote:
> pg_rewind and pg_waldump seem to need the xlogreader code moved to
> src/common, as Andres proposes. I'm not volunteering to tackle that
> right now but I think it might be a good thing to do sometime.
The easier way would be to just keep their current method of building, but do
it as part of src/common.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2022-08-24 15:10 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20 19:45 Inconsistencies around defining FRONTEND Andres Freund <andres@anarazel.de>
2022-08-22 15:48 ` Andres Freund <andres@anarazel.de>
2022-08-23 03:42 ` Andres Freund <andres@anarazel.de>
2022-08-23 21:24 ` Robert Haas <robertmhaas@gmail.com>
2022-08-23 21:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-08-23 22:58 ` Robert Haas <robertmhaas@gmail.com>
2022-08-23 23:24 ` Andres Freund <andres@anarazel.de>
2022-08-23 23:37 ` Robert Haas <robertmhaas@gmail.com>
2022-08-23 23:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-08-24 01:55 ` Andres Freund <andres@anarazel.de>
2022-08-24 14:40 ` Robert Haas <robertmhaas@gmail.com>
2022-08-24 15:10 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox