Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d781c6

Browse files
committed
[ backpatched to 8.0.X.]
> >> 3) I restarted the postmaster both times. I got this error> both times.> >> :25: ERROR: could not load library "C:/Program> >> Files/PostgreSQL/8.0/lib/testtrigfuncs.dll": dynamic load error>> > Yes. We really need to look at fixing that error message. I had> > forgotten it completely :-(>> > Bruce, you think we can sneak that in after feature freeze? I would> > call it a bugfix :-)>> Me too. That's been on the radar for awhile --- please do> send in a patch.Here we go, that wasn't too hard :-)Apart from adding the error handling, it does one more thing: it changesthe errormode when loading the DLLs. Previously if a DLL was broken, orreferenced other DLLs that couldn't be found, a popup dialog box wouldappear on the screen. Which had to be clicked before the backend couldcontinue. This patch also disables the popup error message for DLLloads.I think this is something we should consider doing for the entirebackend - disable those popups, and say we deal with it ourselves. Whatdo you other win32 hackers thinnk about this?In the meantime, this patch fixes the error msgs. Please apply for 8.1and please consider a backpatch to 8.0.Magnus Hagander
1 parent479a8fd commit7d781c6

File tree

1 file changed

+57
-5
lines changed

1 file changed

+57
-5
lines changed

‎src/backend/port/dynloader/win32.c

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,84 @@
1-
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.5 2004/12/02 19:38:50 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.6 2005/08/12 21:23:10 momjian Exp $ */
22

33
#include<windows.h>
4+
#include<stdio.h>
45

56
char*dlerror(void);
67
intdlclose(void*handle);
78
void*dlsym(void*handle,constchar*symbol);
89
void*dlopen(constchar*path,intmode);
910

11+
staticcharlast_dyn_error[512];
12+
13+
staticvoidset_dl_error(void)
14+
{
15+
DWORDerr=GetLastError();
16+
17+
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
18+
FORMAT_MESSAGE_FROM_SYSTEM,
19+
NULL,
20+
err,
21+
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
22+
last_dyn_error,
23+
sizeof(last_dyn_error)-1,
24+
NULL)==0)
25+
{
26+
snprintf(last_dyn_error,sizeof(last_dyn_error)-1,
27+
"unknown error %lu",err);
28+
}
29+
}
30+
1031
char*
1132
dlerror(void)
1233
{
13-
return"dynamic load error";
34+
if (last_dyn_error[0])
35+
returnlast_dyn_error;
36+
else
37+
returnNULL;
1438
}
1539

1640
int
1741
dlclose(void*handle)
1842
{
19-
returnFreeLibrary((HMODULE)handle) ?0 :1;
43+
if (!FreeLibrary((HMODULE)handle))
44+
{
45+
set_dl_error();
46+
return1;
47+
}
48+
last_dyn_error[0]=0;
49+
return0;
2050
}
2151

2252
void*
2353
dlsym(void*handle,constchar*symbol)
2454
{
25-
return (void*)GetProcAddress((HMODULE)handle,symbol);
55+
void*ptr;
56+
ptr=GetProcAddress((HMODULE)handle,symbol);
57+
if (!ptr)
58+
{
59+
set_dl_error();
60+
returnNULL;
61+
}
62+
last_dyn_error[0]=0;
63+
returnptr;
2664
}
2765

2866
void*
2967
dlopen(constchar*path,intmode)
3068
{
31-
return (void*)LoadLibrary(path);
69+
HMODULEh;
70+
intprevmode;
71+
72+
/* Disable popup error messages when loading DLLs */
73+
prevmode=SetErrorMode(SEM_FAILCRITICALERRORS |SEM_NOOPENFILEERRORBOX);
74+
h=LoadLibrary(path);
75+
SetErrorMode(prevmode);
76+
77+
if (!h)
78+
{
79+
set_dl_error();
80+
returnNULL;
81+
}
82+
last_dyn_error[0]=0;
83+
return (void*)h;
3284
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp