通用文件访问函数提供了对数据库服务器上的文件的本地访问接口。只有GBase 8c目录和log_directory目录里面的文件可以访问。使用相对路径访问GBase 8c目录里面的文件,以及匹配log_directory配置而设置的路径访问日志文件。只有数据库初始化用户才能使用这些函数。
pg_ls_dir(dirname text)
描述:列出目录中的文件。
返回值类型:setof text
备注:pg_ls_dir返回指定目录里面的除了特殊项“.”和“..”之外所有名称。
示例:
gbase=# SELECT pg_ls_dir('./');
pg_ls_dir
----------------------
global
pg_xlog
pg_clog
pg_csnlog
pg_notify
pg_serial
pg_snapshots
pg_twophase
pg_multixact
base
pg_replslot
pg_tblspc
pg_stat_tmp
pg_llog
pg_errorinfo
undo
pg_logical
pg_location
PG_VERSION
pg_ctl.lock
postgresql.conf.lock
postmaster.pid.lock
mot.conf
gs_gazelle.conf
pg_hba.conf
pg_ident.conf
postgresql.conf.bak
server.crt
server.key
cacert.pem
server.key.cipher
server.key.rand
pg_hba.conf.lock
pg_hba.conf.bak
gaussdb.state
postmaster.opts
gswlm_userinfo.cfg
postgresql.conf
postmaster.pid
(39 rows)
pg_read_file(filename text, offset bigint, length bigint)
描述:返回一个文本文件的内容。
返回值类型:text
备注:pg_read_file返回一个文本文件的一部分,从offset开始,最多返回length字节(如果先达到文件结尾,则小于这个数值)。如果offset是负数,则它是相对于文件结尾回退的长度。如果省略了offset和length,则返回整个文件。
示例:
gbase=# SELECT pg_read_file('postmaster.pid',0,100);
pg_read_file
-------------------------------------------
7961 +
/home/gbase/project/install/data/dn/dn1_1+
1651723153 +
20008 +
/home/gbase/gbase8c/tmp +
[local_ip] +
2
(1 row)
————————————————
版权声明:本文为CSDN博主「大壮十二」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41614765/article/details/125976731
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




