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

Commita28f117

Browse files
committed
This is the second time I've answered this exact same problem in two
days. It seems to be a FAQ, and I think I know why. When creating a 'c'language function, CREATE FUNCTION is fed the shared object filename,and seems to succeed. Only when trying to use the function is an errorthrown, by which time the coder thinks something's wrong with executingthe code, not with loading it.I think I once saw it proposed to load shared objects at function creationtime, but that idea was shot down on the grounds of resident memory bloat,ISTR. Here's a patch for a compromise: all it does is stat() the file,just like the loader code does, so that the errors caused by non existentfiles, and no directory 'x' permissions (the most common ones, it seems),get caught while the developer is still thinking about code loading. Itdoesn't catch all errors (like the code not being readable by the postgresuser) but seems to catch the most common, without actually opening the file.What do you think?Ross
1 parent5e02f6b commita28f117

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎src/backend/commands/define.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.41 2000/04/13 11:51:07 wieck Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.42 2000/05/12 18:51:59 momjian Exp $
1414
*
1515
* DESCRIPTION
1616
* The "DefineFoo" routines take the parse tree and pick out the
@@ -35,6 +35,8 @@
3535
*/
3636
#include<ctype.h>
3737
#include<math.h>
38+
#include<sys/stat.h>
39+
3840

3941
#include"postgres.h"
4042

@@ -180,16 +182,24 @@ static void
180182
interpret_AS_clause(constchar*languageName,constList*as,
181183
char**prosrc_str_p,char**probin_str_p)
182184
{
185+
structstatstat_buf;
186+
183187
Assert(as!=NIL);
184188

185189
if (strcmp(languageName,"C")==0)
186190
{
187191

188192
/*
189193
* For "C" language, store the file name in probin and, when
190-
* given, the link symbol name in prosrc.
194+
* given, the link symbol name in prosrc. But first, stat the
195+
* file to make sure it's there!
191196
*/
197+
198+
if (stat(strVal(lfirst(as)),&stat_buf)==-1)
199+
elog(ERROR,"stat failed on file '%s': %m",strVal(lfirst(as)));
200+
192201
*probin_str_p=strVal(lfirst(as));
202+
193203
if (lnext(as)==NULL)
194204
*prosrc_str_p="-";
195205
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp