Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eeec317

Browse files
committed
Determines the PKGLIBDIR equivalent under win32. Requires pgsql lib and
bin directories to be packaged under the same root directory (eg. <some path>/pgsql/bin and <some path>/pgsql/lib) for the win32 port, which does not appear to be an onerous restriction. Claudio Natoli
1 parent 943eae9 commit eeec317

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/backend/utils/fmgr/dfmgr.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.70 2004/02/17 03:35:57 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.71 2004/03/09 05:06:45 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -343,6 +343,9 @@ substitute_libpath_macro(const char *name)
343343
{
344344
size_t macroname_len;
345345
char *replacement = NULL;
346+
#ifdef WIN32
347+
char basename[MAXPGPATH];
348+
#endif
346349

347350
AssertArg(name != NULL);
348351

@@ -356,7 +359,26 @@ substitute_libpath_macro(const char *name)
356359
#endif
357360

358361
if (strncmp(name, "$libdir", macroname_len) == 0)
362+
#ifndef WIN32
359363
replacement = PKGLIBDIR;
364+
#else
365+
{
366+
char *p;
367+
if (GetModuleFileName(NULL,basename,MAXPGPATH) == 0)
368+
ereport(FATAL,
369+
(errmsg("GetModuleFileName failed (%i)",(int)GetLastError())));
370+
371+
canonicalize_path(basename);
372+
if ((p = last_path_separator(basename)) == NULL)
373+
ereport(FATAL,
374+
(errmsg("unexpected failure in determining PKGLIBDIR (%s)",basename)));
375+
else
376+
*p = '\0';
377+
378+
strcat(basename,"/../lib");
379+
replacement = basename;
380+
}
381+
#endif
360382
else
361383
ereport(ERROR,
362384
(errcode(ERRCODE_INVALID_NAME),

0 commit comments

Comments
 (0)