Skip to content

Commit a9fad44

Browse files
committed
Move find_my_exec() way up into main.c so it is available to the
timezone code and other places. Remove elog() calls from find_my_exec; do fprintf(stderr) instead. We can then remove the exec.c handling in the makefile because it doesn't have to be built to suppress elog calls.
1 parent da401bd commit a9fad44

File tree

10 files changed

+92
-116
lines changed

10 files changed

+92
-116
lines changed

src/backend/main/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.78 2004/05/18 20:18:57 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -241,6 +241,14 @@ main(int argc, char *argv[])
241241
#endif /* !WIN32 */
242242
}
243243

244+
if (find_my_exec(argv[0], my_exec_path) < 0)
245+
{
246+
fprintf(stderr,
247+
gettext("%s: could not locate my own executable path"),
248+
argv[0]);
249+
exit(1);
250+
}
251+
244252
/*
245253
* Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain,
246254
* SubPostmasterMain, pgstat_main, pgstat_mainChild or BootstrapMain

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.388 2004/05/17 14:35:29 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.389 2004/05/18 20:18:57 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -295,8 +295,6 @@ __attribute__((format(printf, 1, 2)));
295295

296296
#ifdef EXEC_BACKEND
297297

298-
static char postgres_exec_path[MAXPGPATH];
299-
300298
#ifdef WIN32
301299
pid_t win32_forkexec(const char* path, char *argv[]);
302300

@@ -690,13 +688,6 @@ PostmasterMain(int argc, char *argv[])
690688
(errmsg_internal("-----------------------------------------")));
691689
}
692690

693-
/*
694-
* On some systems our dynloader code needs the executable's pathname.
695-
*/
696-
if (find_my_exec(argv[0], my_exec_path) < 0)
697-
ereport(FATAL,
698-
(errmsg("%s: could not locate my own executable path",
699-
progname)));
700691
if (strlen(pkglib_path) == 0)
701692
get_pkglib_path(my_exec_path, pkglib_path);
702693

src/backend/tcop/postgres.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.407 2004/05/17 14:35:31 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.408 2004/05/18 20:18:58 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2549,6 +2549,9 @@ PostgresMain(int argc, char *argv[], const char *username)
25492549
}
25502550
Assert(DataDir);
25512551

2552+
if (strlen(pkglib_path) == 0)
2553+
get_pkglib_path(my_exec_path, pkglib_path);
2554+
25522555
/* Acquire configuration parameters */
25532556
if (IsUnderPostmaster)
25542557
{
@@ -2645,16 +2648,6 @@ PostgresMain(int argc, char *argv[], const char *username)
26452648
argv[0])));
26462649
}
26472650

2648-
/*
2649-
* On some systems our dynloader code needs the executable's pathname.
2650-
*/
2651-
if (strlen(my_exec_path) == 0 && find_my_exec(argv[0], my_exec_path) < 0)
2652-
ereport(FATAL,
2653-
(errmsg("%s: could not locate postgres executable",
2654-
argv[0])));
2655-
if (strlen(pkglib_path) == 0)
2656-
get_pkglib_path(my_exec_path, pkglib_path);
2657-
26582651
/*
26592652
* Validate we have been given a reasonable-looking DataDir (if
26602653
* under postmaster, assume postmaster did this already).

src/bin/initdb/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.38 2004/05/17 14:35:33 momjian Exp $
8+
# $PostgreSQL: pgsql/src/bin/initdb/Makefile,v 1.39 2004/05/18 20:18:58 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -15,17 +15,13 @@ include $(top_builddir)/src/Makefile.global
1515

1616
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS)
1717

18-
OBJS= initdb.o \
19-
$(filter exec.o, $(LIBOBJS))
18+
OBJS= initdb.o
2019

2120
all: submake-libpq submake-libpgport initdb
2221

2322
initdb: $(OBJS) $(libpq_builddir)/libpq.a
2423
$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
2524

26-
exec.c: % : $(top_srcdir)/src/port/%
27-
rm -f $@ && $(LN_S) $< .
28-
2925
install: all installdirs
3026
$(INSTALL_PROGRAM) initdb$(X) $(DESTDIR)$(bindir)/initdb$(X)
3127

@@ -36,7 +32,7 @@ uninstall:
3632
rm -f $(DESTDIR)$(bindir)/initdb$(X)
3733

3834
clean distclean maintainer-clean:
39-
rm -f initdb$(X) $(OBJS) exec.c
35+
rm -f initdb$(X) $(OBJS)
4036

4137

4238
# ensure that changes in datadir propagate into object file

src/bin/pg_dump/Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.47 2004/05/11 21:57:14 momjian Exp $
8+
# $PostgreSQL: pgsql/src/bin/pg_dump/Makefile,v 1.48 2004/05/18 20:18:58 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -18,7 +18,6 @@ override CPPFLAGS += -DFRONTEND
1818
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
1919
pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
2020
dumputils.o
21-
PG_DUMPALL_OBJS = $(filter exec.o, $(LIBOBJS))
2221

2322
EXTRA_OBJS = $(top_builddir)/src/backend/parser/keywords.o
2423

@@ -33,11 +32,8 @@ pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_builddir)/libpq.a
3332
pg_restore: pg_restore.o $(OBJS) $(libpq_builddir)/libpq.a
3433
$(CC) $(CFLAGS) pg_restore.o $(OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
3534

36-
pg_dumpall: pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(libpq_builddir)/libpq.a
37-
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(PG_DUMPALL_OBJS) $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
38-
39-
exec.c: % : $(top_srcdir)/src/port/%
40-
rm -f $@ && $(LN_S) $< .
35+
pg_dumpall: pg_dumpall.o dumputils.o $(libpq_builddir)/libpq.a
36+
$(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(EXTRA_OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
4137

4238
.PHONY: submake-backend
4339
submake-backend:
@@ -56,4 +52,4 @@ uninstall:
5652
rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
5753

5854
clean distclean maintainer-clean:
59-
rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o exec.c
55+
rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o

src/bin/psql/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.44 2004/05/17 14:35:33 momjian Exp $
8+
# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.45 2004/05/18 20:18:58 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -19,8 +19,7 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) -DFRONTEND
1919

2020
OBJS= command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
2121
startup.o prompt.o variables.o large_obj.o print.o describe.o \
22-
psqlscan.o tab-complete.o mbprint.o \
23-
$(filter exec.o, $(LIBOBJS))
22+
psqlscan.o tab-complete.o mbprint.o
2423

2524
FLEXFLAGS = -Cfe
2625

@@ -30,9 +29,6 @@ all: submake-libpq submake-libpgport psql
3029
psql: $(OBJS) $(libpq_builddir)/libpq.a
3130
$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@$(X)
3231

33-
exec.c: % : $(top_srcdir)/src/port/%
34-
rm -f $@ && $(LN_S) $< .
35-
3632
help.o: $(srcdir)/sql_help.h
3733

3834
ifdef PERL
@@ -64,7 +60,7 @@ uninstall:
6460

6561
# psqlscan.c is in the distribution tarball, so is not cleaned here
6662
clean distclean:
67-
rm -f psql$(X) $(OBJS) exec.c
63+
rm -f psql$(X) $(OBJS)
6864

6965
maintainer-clean: distclean
7066
rm -f $(srcdir)/sql_help.h $(srcdir)/psqlscan.c

src/bin/psql/print.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.46 2004/01/24 20:43:26 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.47 2004/05/18 20:18:58 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -388,7 +388,10 @@ print_aligned_text(const char *title, const char *const * headers,
388388
for (ptr = footers; *ptr; ptr++)
389389
fprintf(fout, "%s\n", *ptr);
390390

391+
#ifndef __MINGW32__
392+
/* for some reason MinGW outputs an extra newline, so this supresses it */
391393
fputc('\n', fout);
394+
#endif
392395

393396
/* clean up */
394397
free(cell_w);

src/interfaces/ecpg/preproc/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.104 2004/05/17 14:35:34 momjian Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.105 2004/05/18 20:18:58 momjian Exp $
22

33
subdir = src/interfaces/ecpg/preproc
44
top_builddir = ../../../..
@@ -19,17 +19,13 @@ endif
1919
override CFLAGS += $(PTHREAD_CFLAGS)
2020

2121
OBJS= preproc.o type.o ecpg.o ecpg_keywords.o output.o\
22-
keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o \
23-
$(filter exec.o, $(LIBOBJS))
22+
keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o
2423

2524
all: submake-libpgport ecpg
2625

2726
ecpg: $(OBJS)
2827
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
2928

30-
exec.c: % : $(top_srcdir)/src/port/%
31-
rm -f $@ && $(LN_S) $< .
32-
3329
# pgc is compiled as part of preproc
3430
preproc.o: $(srcdir)/pgc.c
3531

@@ -66,7 +62,7 @@ uninstall:
6662
rm -f $(DESTDIR)$(bindir)/ecpg$(X)
6763

6864
clean distclean:
69-
rm -f *.o ecpg$(X) exec.c
65+
rm -f *.o ecpg$(X)
7066
# garbage from partial builds
7167
@rm -f y.tab.c y.tab.h
7268
# garbage from development

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy