Skip to content

Commit 9e02e20

Browse files
committed
MinGW: Link with shell32.dll instead of shfolder.dll.
This improves consistency with the MSVC build. On buildfarm member narwhal, since commit 846e91e, shfolder.dll:SHGetFolderPath() crashes when dblink calls it by way of pqGetHomeDirectory(). Back-patch to 9.4, where that commit first appeared. How it caused this regression remains a mystery. This is a partial revert of commit 889f038, which adopted shfolder.dll for Windows NT 4.0 compatibility. PostgreSQL 8.2 dropped support for that operating system.
1 parent 7a14edb commit 9e02e20

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

src/Makefile.global.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,9 @@ LIBOBJS = @LIBOBJS@
547547

548548
LIBS := -lpgcommon -lpgport $(LIBS)
549549

550-
# to make ws2_32.lib the last library, and always link with shfolder,
551-
# so SHGetFolderName isn't picked up from shell32.dll
550+
# to make ws2_32.lib the last library
552551
ifeq ($(PORTNAME),win32)
553-
LIBS += -lws2_32 -lshfolder
552+
LIBS += -lws2_32
554553
endif
555554

556555
# Not really standard libc functions, used by the backend.

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ SHLIB_PREREQS = submake-libpq submake-pgtypeslib
3838

3939
SHLIB_EXPORTS = exports.txt
4040

41-
ifeq ($(PORTNAME), win32)
42-
# Link to shfolder.dll instead of shell32.dll
43-
SHLIB_LINK += -lshfolder
44-
endif
45-
4641
PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
4742

4843
all: all-lib

src/interfaces/libpq/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ else
7070
SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
7171
endif
7272
ifeq ($(PORTNAME), win32)
73-
SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
73+
SHLIB_LINK += -lshell32 -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
7474
endif
7575

7676
SHLIB_EXPORTS = exports.txt

src/interfaces/libpq/win32.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ CPP_SBRS=.
208208
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
209209

210210
LINK32=link.exe
211-
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS) $(KFW_LIB) $(ADD_SECLIB) \
211+
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib ws2_32.lib secur32.lib $(SSL_LIBS) $(KFW_LIB) $(ADD_SECLIB) \
212212
/nologo /subsystem:windows /dll $(LOPT) /incremental:no \
213213
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:$(CPU) \
214214
/out:"$(OUTDIR)\$(OUTFILENAME).dll"\

src/port/path.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,11 @@ get_home_path(char *ret_path)
785785
char *tmppath;
786786

787787
/*
788-
* Note: We use getenv here because the more modern
789-
* SHGetSpecialFolderPath() will force us to link with shell32.lib which
790-
* eats valuable desktop heap.
788+
* Note: We use getenv() here because the more modern SHGetFolderPath()
789+
* would force the backend to link with shell32.lib, which eats valuable
790+
* desktop heap. XXX This function is used only in psql, which already
791+
* brings in shell32 via libpq. Moving this function to its own file
792+
* would keep it out of the backend, freeing it from this concern.
791793
*/
792794
tmppath = getenv("APPDATA");
793795
if (!tmppath)

0 commit comments

Comments
 (0)