Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
761a0bb6
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
761a0bb6
编写于
5月 17, 2001
作者:
P
Peter Eisentraut
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add dynamic_library_path parameter and automatic appending of shared
library extension.
上级
8266e8a8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
252 addition
and
5 deletion
+252
-5
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+44
-1
src/backend/utils/fmgr/Makefile
src/backend/utils/fmgr/Makefile
+4
-1
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/dfmgr.c
+197
-1
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+5
-1
src/include/fmgr.h
src/include/fmgr.h
+2
-1
未找到文件。
doc/src/sgml/runtime.sgml
浏览文件 @
761a0bb6
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.6
6 2001/05/12 22:51:35
petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.6
7 2001/05/17 17:44:17
petere Exp $
-->
<Chapter Id="runtime">
...
...
@@ -996,6 +996,49 @@ env PGOPTIONS='-c geqo=off' psql
</listitem>
</varlistentry>
<varlistentry>
<term>DYNAMIC_LIBRARY_PATH (<type>string</type>)</term>
<listitem>
<para>
If a dynamically loadable module needs to be opened and the
specified name does not have a directory component (i.e., the
name does not contain a slash), the system will search this
path for the specified file. (The name that is used is the
name specified in the <command>CREATE FUNCTION</command> or
<command>LOAD</command> command.)
</para>
<para>
The value for dynamic_library_path has to be a colon-separated
list of absolute directory names. If a directory name starts
with the special value <literal>$libdir</literal>, the
compiled-in PostgreSQL library directory, which is where the
modules provided by the PostgreSQL distribution are installed,
is substituted. An example value:
<informalexample>
<programlisting>
dynamic_library_path = '/usr/local/lib:/home/my_project/lib:$libdir:$libdir/contrib'
</programlisting>
</informalexample>
</para>
<para>
The default value for this parameter is
<literal>$libdir</literal>. If the value is set to the empty
string, the automatic path search is turned off.
</para>
<para>
This parameter can be changed at run time by superusers, but
note that a setting done that way will only persist till the
end of the client connection, so this method should be
reserved for development purposes. The recommended way to set
this parameter is in the <filename>postgresql.conf</filename>
configuration file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<indexterm>
<primary>fsync</primary>
...
...
src/backend/utils/fmgr/Makefile
浏览文件 @
761a0bb6
...
...
@@ -4,7 +4,7 @@
# Makefile for utils/fmgr
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/fmgr/Makefile,v 1.1
0 2000/08/31 16:10:50
petere Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/fmgr/Makefile,v 1.1
1 2001/05/17 17:44:18
petere Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -14,6 +14,9 @@ include $(top_builddir)/src/Makefile.global
OBJS
=
dfmgr.o fmgr.o
override
CPPFLAGS
+=
-DLIBDIR
=
\"
$(libdir)
\"
-DDLSUFFIX
=
\"
$(DLSUFFIX)
\"
all
:
SUBSYS.o
SUBSYS.o
:
$(OBJS)
...
...
src/backend/utils/fmgr/dfmgr.c
浏览文件 @
761a0bb6
...
...
@@ -8,16 +8,18 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.4
8 2001/03/22 03:59:58 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.4
9 2001/05/17 17:44:18 petere
Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "dynloader.h"
#include "miscadmin.h"
#include "utils/dynamic_loader.h"
...
...
@@ -44,6 +46,12 @@ static DynamicFileList *file_tail = (DynamicFileList *) NULL;
#define SAME_INODE(A,B) ((A).st_ino == (B).inode && (A).st_dev == (B).device)
char
*
Dynamic_library_path
;
static
bool
file_exists
(
const
char
*
name
);
static
char
*
find_in_dynamic_libpath
(
const
char
*
basename
);
static
char
*
expand_dynamic_library_name
(
const
char
*
name
);
/*
* Load the specified dynamic-link library file, and look for a function
...
...
@@ -60,6 +68,11 @@ load_external_function(char *filename, char *funcname,
PGFunction
retval
;
char
*
load_error
;
struct
stat
stat_buf
;
char
*
fullname
;
fullname
=
expand_dynamic_library_name
(
filename
);
if
(
fullname
)
filename
=
fullname
;
/*
* Scan the list of loaded FILES to see if the file has been loaded.
...
...
@@ -143,6 +156,11 @@ load_file(char *filename)
DynamicFileList
*
file_scanner
,
*
p
;
struct
stat
stat_buf
;
char
*
fullname
;
fullname
=
expand_dynamic_library_name
(
filename
);
if
(
fullname
)
filename
=
fullname
;
/*
* We need to do stat() in order to determine whether this is the same
...
...
@@ -181,3 +199,181 @@ load_file(char *filename)
load_external_function
(
filename
,
(
char
*
)
NULL
,
false
);
}
static
bool
file_exists
(
const
char
*
name
)
{
struct
stat
st
;
AssertArg
(
name
!=
NULL
);
if
(
stat
(
name
,
&
st
)
==
0
)
return
true
;
else
if
(
!
(
errno
==
ENOENT
||
errno
==
ENOTDIR
||
errno
==
EACCES
))
elog
(
ERROR
,
"stat failed on %s: %s"
,
name
,
strerror
(
errno
));
return
false
;
}
/* Example format: ".so" */
#ifndef DLSUFFIX
#error "DLSUFFIX must be defined to compile this file."
#endif
/* Example format: "/usr/local/pgsql/lib" */
#ifndef LIBDIR
#error "LIBDIR needs to be defined to compile this file."
#endif
/*
* If name contains a slash, check if the file exists, if so return
* the name. Else (no slash) try to expand using search path (see
* find_in_dynamic_libpath below); if that works, return the fully
* expanded file name. If the previous failed, append DLSUFFIX and
* try again. If all fails, return NULL. The return value is
* palloc'ed.
*/
static
char
*
expand_dynamic_library_name
(
const
char
*
name
)
{
bool
have_slash
;
char
*
new
;
size_t
len
;
AssertArg
(
name
);
have_slash
=
(
strchr
(
name
,
'/'
)
!=
NULL
);
if
(
!
have_slash
)
{
char
*
full
;
full
=
find_in_dynamic_libpath
(
name
);
if
(
full
)
return
full
;
}
else
{
if
(
file_exists
(
name
))
return
pstrdup
(
name
);
}
len
=
strlen
(
name
);
new
=
palloc
(
len
+
strlen
(
DLSUFFIX
)
+
1
);
strcpy
(
new
,
name
);
strcpy
(
new
+
len
,
DLSUFFIX
);
if
(
!
have_slash
)
{
char
*
full
;
full
=
find_in_dynamic_libpath
(
new
);
pfree
(
new
);
if
(
full
)
return
full
;
}
else
{
if
(
file_exists
(
new
))
return
new
;
}
return
NULL
;
}
/*
* Search for a file called 'basename' in the colon-separated search
* path 'path'. If the file is found, the full file name is returned
* in palloced memory. The the file is not found, return NULL.
*/
static
char
*
find_in_dynamic_libpath
(
const
char
*
basename
)
{
const
char
*
p
;
char
*
full
;
size_t
len
;
size_t
baselen
;
AssertArg
(
basename
!=
NULL
);
AssertArg
(
strchr
(
basename
,
'/'
)
==
NULL
);
AssertState
(
Dynamic_library_path
!=
NULL
);
p
=
Dynamic_library_path
;
if
(
strlen
(
p
)
==
0
)
return
NULL
;
baselen
=
strlen
(
basename
);
do
{
len
=
strcspn
(
p
,
":"
);
if
(
len
==
0
)
elog
(
ERROR
,
"zero length dynamic_library_path component"
);
/* substitute special value */
if
(
p
[
0
]
==
'$'
)
{
size_t
varname_len
=
strcspn
(
p
+
1
,
"/"
)
+
1
;
const
char
*
replacement
=
NULL
;
size_t
repl_len
;
if
(
strncmp
(
p
,
"$libdir"
,
varname_len
)
==
0
)
replacement
=
LIBDIR
;
else
elog
(
ERROR
,
"invalid dynamic_library_path specification"
);
repl_len
=
strlen
(
replacement
);
if
(
p
[
varname_len
]
==
'\0'
)
{
full
=
palloc
(
repl_len
+
1
+
baselen
+
1
);
snprintf
(
full
,
repl_len
+
1
+
baselen
+
1
,
"%s/%s"
,
replacement
,
basename
);
}
else
{
full
=
palloc
(
repl_len
+
(
len
-
varname_len
)
+
1
+
baselen
+
1
);
strcpy
(
full
,
replacement
);
strncat
(
full
,
p
+
varname_len
,
len
-
varname_len
);
full
[
repl_len
+
(
len
-
varname_len
)]
=
'\0'
;
strcat
(
full
,
"/"
);
strcat
(
full
,
basename
);
}
}
/* regular case */
else
{
/* only absolute paths */
if
(
p
[
0
]
!=
'/'
)
elog
(
ERROR
,
"dynamic_library_path component is not absolute"
);
full
=
palloc
(
len
+
1
+
baselen
+
1
);
strncpy
(
full
,
p
,
len
);
full
[
len
]
=
'/'
;
strcpy
(
full
+
len
+
1
,
basename
);
}
if
(
DebugLvl
>
1
)
elog
(
DEBUG
,
"find_in_dynamic_libpath: trying %s"
,
full
);
if
(
file_exists
(
full
))
return
full
;
pfree
(
full
);
if
(
p
[
len
]
==
'\0'
)
break
;
else
p
+=
len
+
1
;
}
while
(
1
);
return
NULL
;
}
src/backend/utils/misc/guc.c
浏览文件 @
761a0bb6
...
...
@@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.3
5 2001/03/22 17:41:47 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.3
6 2001/05/17 17:44:18 petere
Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
...
...
@@ -22,6 +22,7 @@
#include "access/xlog.h"
#include "commands/async.h"
#include "fmgr.h"
#include "libpq/auth.h"
#include "libpq/pqcomm.h"
#include "miscadmin.h"
...
...
@@ -328,6 +329,9 @@ static struct config_real
static
struct
config_string
ConfigureNamesString
[]
=
{
{
"dynamic_library_path"
,
PGC_SUSET
,
&
Dynamic_library_path
,
"$libdir"
,
NULL
,
NULL
},
{
"krb_server_keyfile"
,
PGC_POSTMASTER
,
&
pg_krb_server_keyfile
,
PG_KRB_SRVTAB
,
NULL
,
NULL
},
...
...
src/include/fmgr.h
浏览文件 @
761a0bb6
...
...
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: fmgr.h,v 1.1
3 2001/03/22 04:00:25 momjian
Exp $
* $Id: fmgr.h,v 1.1
4 2001/05/17 17:44:18 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -350,6 +350,7 @@ extern Oid fmgr_internal_function(const char *proname);
extern
PGFunction
load_external_function
(
char
*
filename
,
char
*
funcname
,
bool
signalNotFound
);
extern
void
load_file
(
char
*
filename
);
extern
char
*
Dynamic_library_path
;
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录