public inbox for [email protected]help / color / mirror / Atom feed
[PATCH v19 02/10] pg_stat_file and pg_ls_dir_* to use lstat().. 3+ messages / 3 participants [nested] [flat]
* [PATCH v19 02/10] pg_stat_file and pg_ls_dir_* to use lstat().. @ 2020-03-30 23:59 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Justin Pryzby @ 2020-03-30 23:59 UTC (permalink / raw) pg_ls_dir_* will now skip (no longer show) symbolic links, same as other non-regular file types, as we advertize we do since 8b6d94cf6. That seems to be the intented behavior, since irregular file types are 1) less portable; and, 2) we don't currently show a file's type except for "bool is_dir". pg_stat_file will now 1) show metadata of links themselves, rather than their target; and, 2) specifically, show links to directories with "is_dir=false"; and, 3) not error on broken symlinks. --- doc/src/sgml/func.sgml | 2 +- src/backend/utils/adt/genfile.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 9f47745c5a..b7c450ea29 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -25881,7 +25881,7 @@ SELECT convert_from(pg_read_binary_file('file_in_utf8.txt'), 'UTF8'); Returns a record containing the file's size, last access time stamp, last modification time stamp, last file status change time stamp (Unix platforms only), file creation time stamp (Windows only), and a flag - indicating if it is a directory (or a symbolic link to a directory). + indicating if it is a directory. </para> <para> This function is restricted to superusers by default, but other users diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index ceaa6180da..219ac160f8 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -370,7 +370,7 @@ pg_stat_file(PG_FUNCTION_ARGS) filename = convert_and_check_filename(filename_t); - if (stat(filename, &fst) < 0) + if (lstat(filename, &fst) < 0) { if (missing_ok && errno == ENOENT) PG_RETURN_NULL(); @@ -596,7 +596,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, bool missing_ok) /* Get the file info */ snprintf(path, sizeof(path), "%s/%s", dir, de->d_name); - if (stat(path, &attrib) < 0) + if (lstat(path, &attrib) < 0) { /* Ignore concurrently-deleted files, else complain */ if (errno == ENOENT) -- 2.17.0 --S0GG+JvAI2G0KxBG Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v19-0003-Add-tests-on-pg_ls_dir-before-changing-it.patch" ^ permalink raw reply [nested|flat] 3+ messages in thread
* minor doc change in src/sgml/xfunc.sgml @ 2024-06-17 03:24 jian he <[email protected]> 0 siblings, 1 reply; 3+ messages in thread From: jian he @ 2024-06-17 03:24 UTC (permalink / raw) To: pgsql-hackers hi. simlar to https://www.postgresql.org/docs/devel//xfunc-c.html#XFUNC-ADDIN-WAIT-EVENTS in https://www.postgresql.org/docs/devel//xfunc-c.html#XFUNC-ADDIN-INJECTION-POINTS do we need to add a sentence like " An injections points usage example can be found in src/test/modules/injection_points in the PostgreSQL source tree." before "Enabling injections points requires --enable-injection-points with configure or -Dinjection_points=true with Meson." ? ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: minor doc change in src/sgml/xfunc.sgml @ 2024-06-17 04:37 Michael Paquier <[email protected]> parent: jian he <[email protected]> 0 siblings, 0 replies; 3+ messages in thread From: Michael Paquier @ 2024-06-17 04:37 UTC (permalink / raw) To: jian he <[email protected]>; +Cc: pgsql-hackers On Mon, Jun 17, 2024 at 11:24:09AM +0800, jian he wrote: > in https://www.postgresql.org/docs/devel//xfunc-c.html#XFUNC-ADDIN-INJECTION-POINTS > do we need to add a sentence like " An injections points usage example > can be found in src/test/modules/injection_points in the PostgreSQL > source tree." > before "Enabling injections points requires --enable-injection-points > with configure or -Dinjection_points=true with Meson." > ? Indeed. I intended originally to add a pointer to the module in the docs, but it somewhat got lost in the rebases of the patch. Will fix, thanks for the report! -- Michael Attachments: [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc) download ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-06-17 04:37 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-03-30 23:59 [PATCH v19 02/10] pg_stat_file and pg_ls_dir_* to use lstat().. Justin Pryzby <[email protected]> 2024-06-17 03:24 minor doc change in src/sgml/xfunc.sgml jian he <[email protected]> 2024-06-17 04:37 ` Re: minor doc change in src/sgml/xfunc.sgml Michael Paquier <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox