public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v17 02/10] pg_stat_file and pg_ls_dir_* to use lstat()..
5+ messages / 4 participants
[nested] [flat]

* [PATCH v17 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; 5+ 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 e0d1eff6b5..d9b3598977 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -25861,7 +25861,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


--4LFBTxd4L5NLO6ly
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v17-0003-Add-tests-on-pg_ls_dir-before-changing-it.patch"



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

* Re: Testing autovacuum wraparound (including failsafe)
@ 2023-03-09 06:46  Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2023-03-09 06:46 UTC (permalink / raw)
  To: Peter Geoghegan <[email protected]>; +Cc: Heikki Linnakangas <[email protected]>; Ian Lawrence Barwick <[email protected]>; Masahiko Sawada <[email protected]>; Andres Freund <[email protected]>; Anastasia Lubennikova <[email protected]>; pgsql-hackers

On Tue, Mar 07, 2023 at 09:21:00PM -0800, Peter Geoghegan wrote:
> Surely your tap test should be using single user mode?  Perhaps you
> missed the obnoxious HINT, that's part of the WARNING that the test
> parses?  ;-)

I may be missing something, but you cannot use directly a "postgres"
command in a TAP test, can you?  See 1a9d802, that has fixed a problem
when TAP tests run with a privileged account on Windows.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

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

* Re: Testing autovacuum wraparound (including failsafe)
@ 2023-03-12 04:46  Peter Geoghegan <[email protected]>
  parent: Michael Paquier <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter Geoghegan @ 2023-03-12 04:46 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; +Cc: Heikki Linnakangas <[email protected]>; Ian Lawrence Barwick <[email protected]>; Masahiko Sawada <[email protected]>; Andres Freund <[email protected]>; Anastasia Lubennikova <[email protected]>; pgsql-hackers

On Wed, Mar 8, 2023 at 10:47 PM Michael Paquier <[email protected]> wrote:
> I may be missing something, but you cannot use directly a "postgres"
> command in a TAP test, can you?  See 1a9d802, that has fixed a problem
> when TAP tests run with a privileged account on Windows.

I was joking. But I did have a real point: once we have tests for the
xidStopLimit mechanism, why not take the opportunity to correct the
long standing issue with the documentation advising the use of single
user mode?

-- 
Peter Geoghegan






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

* Re: Testing autovacuum wraparound (including failsafe)
@ 2023-03-13 22:25  Jacob Champion <[email protected]>
  parent: Peter Geoghegan <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Jacob Champion @ 2023-03-13 22:25 UTC (permalink / raw)
  To: Peter Geoghegan <[email protected]>; +Cc: Michael Paquier <[email protected]>; Heikki Linnakangas <[email protected]>; Ian Lawrence Barwick <[email protected]>; Masahiko Sawada <[email protected]>; Andres Freund <[email protected]>; Anastasia Lubennikova <[email protected]>; pgsql-hackers

On Sat, Mar 11, 2023 at 8:47 PM Peter Geoghegan <[email protected]> wrote:
> I was joking. But I did have a real point: once we have tests for the
> xidStopLimit mechanism, why not take the opportunity to correct the
> long standing issue with the documentation advising the use of single
> user mode?

Does https://commitfest.postgresql.org/42/4128/ address that
independently enough?

--Jacob






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

* Re: Testing autovacuum wraparound (including failsafe)
@ 2023-03-13 23:24  Peter Geoghegan <[email protected]>
  parent: Jacob Champion <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter Geoghegan @ 2023-03-13 23:24 UTC (permalink / raw)
  To: Jacob Champion <[email protected]>; +Cc: Michael Paquier <[email protected]>; Heikki Linnakangas <[email protected]>; Ian Lawrence Barwick <[email protected]>; Masahiko Sawada <[email protected]>; Andres Freund <[email protected]>; Anastasia Lubennikova <[email protected]>; pgsql-hackers

On Mon, Mar 13, 2023 at 3:25 PM Jacob Champion <[email protected]> wrote:
> Does https://commitfest.postgresql.org/42/4128/ address that
> independently enough?

I wasn't aware of that patch. It looks like it does exactly what I was
arguing in favor of. So yes.

-- 
Peter Geoghegan






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


end of thread, other threads:[~2023-03-13 23:24 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 23:59 [PATCH v17 02/10] pg_stat_file and pg_ls_dir_* to use lstat().. Justin Pryzby <[email protected]>
2023-03-09 06:46 Re: Testing autovacuum wraparound (including failsafe) Michael Paquier <[email protected]>
2023-03-12 04:46 ` Re: Testing autovacuum wraparound (including failsafe) Peter Geoghegan <[email protected]>
2023-03-13 22:25   ` Re: Testing autovacuum wraparound (including failsafe) Jacob Champion <[email protected]>
2023-03-13 23:24     ` Re: Testing autovacuum wraparound (including failsafe) Peter Geoghegan <[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