Skip to content

Commit c7611f9

Browse files
committed
On Windows, we know the backend stack size limit because we have to
specify it explicitly in backend/Makefile. Arrange for this value to be known by get_stack_depth_rlimit() too. Per suggestion from Magnus.
1 parent 5e0bc3b commit c7611f9

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/Makefile.global.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.231 2006/10/03 22:18:22 tgl Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.232 2006/10/08 17:15:33 tgl Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -311,6 +311,9 @@ HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
311311
# systems now. May be applicable to other systems to?
312312
ELF_SYSTEM= @ELF_SYS@
313313

314+
# Backend stack size limit has to be hard-wired on Windows (it's in bytes)
315+
WIN32_STACK_RLIMIT=4194304
316+
314317
# Pull in platform-specific magic
315318
include $(top_builddir)/src/Makefile.port
316319

src/backend/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.119 2006/09/09 03:15:40 tgl Exp $
7+
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.120 2006/10/08 17:15:33 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -52,7 +52,7 @@ postgres: $(OBJS) postgres.def libpostgres.a
5252
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
5353
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
5454
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
55-
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,4194304 -o $@$(X) $@.exp $(OBJS) $(LIBS)
55+
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(OBJS) $(LIBS)
5656
rm -f $@.exp $@.base
5757

5858
postgres.def: $(OBJS)
@@ -69,7 +69,7 @@ postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
6969
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
7070
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS)
7171
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
72-
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=4194304 -o $@$(X) $@.exp $(OBJS) $(WIN32RES) $(LIBS)
72+
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(OBJS) $(WIN32RES) $(LIBS)
7373
rm -f $@.exp $@.base
7474

7575
postgres.def: $(OBJS)

src/backend/tcop/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for tcop
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/tcop/Makefile,v 1.25 2003/11/29 19:51:57 pgsql Exp $
7+
# $PostgreSQL: pgsql/src/backend/tcop/Makefile,v 1.26 2006/10/08 17:15:34 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,6 +14,8 @@ include $(top_builddir)/src/Makefile.global
1414

1515
OBJS= dest.o fastpath.o postgres.o pquery.o utility.o
1616

17+
override CPPFLAGS += -DWIN32_STACK_RLIMIT=$(WIN32_STACK_RLIMIT)
18+
1719
all: SUBSYS.o
1820

1921
SUBSYS.o: $(OBJS)

src/backend/tcop/postgres.c

Lines changed: 6 additions & 1 deletion
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.513 2006/10/07 20:16:57 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.514 2006/10/08 17:15:34 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -3678,8 +3678,13 @@ get_stack_depth_rlimit(void)
36783678
}
36793679
return val;
36803680
#else /* no getrlimit */
3681+
#if defined(WIN32) || defined(__CYGWIN__)
3682+
/* On Windows we set the backend stack size in src/backend/Makefile */
3683+
return WIN32_STACK_RLIMIT;
3684+
#else /* not windows ... give up */
36813685
return -1;
36823686
#endif
3687+
#endif
36833688
}
36843689

36853690

0 commit comments

Comments
 (0)