public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v32 08/11] pg_stat_file and pg_ls_dir_* to use lstat()..
3+ messages / 3 participants
[nested] [flat]

* [PATCH v32 08/11] 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 745faa1841f..3650e3d71f2 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -27539,7 +27539,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 3c022cffd5a..e907f399241 100644
--- a/src/backend/utils/adt/genfile.c
+++ b/src/backend/utils/adt/genfile.c
@@ -445,7 +445,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();
@@ -635,7 +635,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, int flags)
 
 		/* 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


--Bne5rrxQd65beI7a
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v32-0009-pg_ls_-pg_stat_file-to-show-file-type.patch"



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Relation bulk write facility
@ 2024-02-28 19:47  Heikki Linnakangas <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Heikki Linnakangas @ 2024-02-28 19:47 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Andres Freund <[email protected]>; Thomas Munro <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Robert Haas <[email protected]>; Peter Smith <[email protected]>; vignesh C <[email protected]>; pgsql-hackers; Melanie Plageman <[email protected]>

On 28/02/2024 18:04, Tom Lane wrote:
> Heikki Linnakangas <[email protected]> writes:
>> On 28/02/2024 00:30, Thomas Munro wrote:
>>> I agree, this should be an error, and we should then remove the test.
> 
>> Done.
> 
> The commit that added that test added a support function
> "get_columns_length" which is now unused.  Should we get rid of that
> as well?

I see you just removed it; thanks!

-- 
Heikki Linnakangas
Neon (https://neon.tech)







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Relation bulk write facility
@ 2024-02-28 22:23  Tom Lane <[email protected]>
  parent: Heikki Linnakangas <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2024-02-28 22:23 UTC (permalink / raw)
  To: Heikki Linnakangas <[email protected]>; +Cc: Andres Freund <[email protected]>; Thomas Munro <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Robert Haas <[email protected]>; Peter Smith <[email protected]>; vignesh C <[email protected]>; pgsql-hackers; Melanie Plageman <[email protected]>

Heikki Linnakangas <[email protected]> writes:
> On 28/02/2024 18:04, Tom Lane wrote:
>> The commit that added that test added a support function
>> "get_columns_length" which is now unused.  Should we get rid of that
>> as well?

> I see you just removed it; thanks!

In the no-good-deed-goes-unpunished department: crake is reporting
that this broke our cross-version upgrade tests.  I'll go fix that.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-02-28 22:23 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 v32 08/11] pg_stat_file and pg_ls_dir_* to use lstat().. Justin Pryzby <[email protected]>
2024-02-28 19:47 Re: Relation bulk write facility Heikki Linnakangas <[email protected]>
2024-02-28 22:23 ` Re: Relation bulk write facility Tom Lane <[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