public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v17 02/10] pg_stat_file and pg_ls_dir_* to use lstat()..
2+ messages / 2 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; 2+ 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] 2+ messages in thread

* New isolation test insert-conflict-do-update-4 outputs rows in alternative ordering
@ 2026-02-24 16:13 Pavel Borisov <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Borisov @ 2026-02-24 16:13 UTC (permalink / raw)
  To: Postgres hackers <[email protected]>

Hi, hackers!

New isolation test insert-conflict-do-update-4 was added by commit 4b760a181ab2

Unlike the previous test (insert-conflict-do-update-3) it doesn't
contain an ordering clause, and when run on a table with a custom
access method, it outputs results in a reverse order.

It's a very minor issue, and the proposed fix is just adding the
missing ORDER BY clause.

Other insert-conflict-do-* isolation tests output just one row except
the mentioned insert-conflict-do-update-3 and
insert-conflict-do-update-4.

The patch is attached

Kind regards,
Pavel Borisov
Supabase


Attachments:

  [application/octet-stream] v1-0001-Fix-sorting-of-output-rows-in-a-new-isolation-tes.patch (2.3K, ../../CALT9ZEHcE6tpvumScYPO6pGk_ASjTjWojLkodHnk33dvRPHXVw@mail.gmail.com/2-v1-0001-Fix-sorting-of-output-rows-in-a-new-isolation-tes.patch)
  download | inline diff:
From 0d27e1505c1009e2f4ad0c482ab28d83ff4a76d9 Mon Sep 17 00:00:00 2001
From: Pavel Borisov <[email protected]>
Date: Tue, 24 Feb 2026 20:00:48 +0400
Subject: [PATCH v1] Fix sorting of output rows in a new isolation test
 introduced in commit 4b760a181ab2

---
 .../isolation/expected/insert-conflict-do-update-4.out    | 8 ++++----
 src/test/isolation/specs/insert-conflict-do-update-4.spec | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/test/isolation/expected/insert-conflict-do-update-4.out b/src/test/isolation/expected/insert-conflict-do-update-4.out
index 6e96e0d12da..80af2798a94 100644
--- a/src/test/isolation/expected/insert-conflict-do-update-4.out
+++ b/src/test/isolation/expected/insert-conflict-do-update-4.out
@@ -12,11 +12,11 @@ step insert1: INSERT INTO upsert VALUES (1, 11, 111)
 step update2a: UPDATE upsert SET i = i + 10 WHERE i = 1;
 step c2: COMMIT;
 step insert1: <... completed>
-step select1: SELECT * FROM upsert;
+step select1: SELECT * FROM upsert ORDER BY i;
  i| j|  k
 --+--+---
-11|10|100
  1|11|111
+11|10|100
 (2 rows)
 
 step c1: COMMIT;
@@ -33,7 +33,7 @@ step insert1: INSERT INTO upsert VALUES (1, 11, 111)
 step update2b: UPDATE upsert SET i = i + 150 WHERE i = 1;
 step c2: COMMIT;
 step insert1: <... completed>
-step select1: SELECT * FROM upsert;
+step select1: SELECT * FROM upsert ORDER BY i;
   i| j|  k
 ---+--+---
   1|11|111
@@ -54,7 +54,7 @@ step insert1: INSERT INTO upsert VALUES (1, 11, 111)
 step delete2: DELETE FROM upsert WHERE i = 1;
 step c2: COMMIT;
 step insert1: <... completed>
-step select1: SELECT * FROM upsert;
+step select1: SELECT * FROM upsert ORDER BY i;
 i| j|  k
 -+--+---
 1|11|111
diff --git a/src/test/isolation/specs/insert-conflict-do-update-4.spec b/src/test/isolation/specs/insert-conflict-do-update-4.spec
index 6297b1d1d6c..a62531660d3 100644
--- a/src/test/isolation/specs/insert-conflict-do-update-4.spec
+++ b/src/test/isolation/specs/insert-conflict-do-update-4.spec
@@ -23,7 +23,7 @@ session s1
 setup           { BEGIN ISOLATION LEVEL READ COMMITTED; }
 step insert1    { INSERT INTO upsert VALUES (1, 11, 111)
                   ON CONFLICT (i) DO UPDATE SET k = EXCLUDED.k; }
-step select1    { SELECT * FROM upsert; }
+step select1    { SELECT * FROM upsert ORDER BY i; }
 step c1         { COMMIT; }
 
 session s2
-- 
2.39.2 (Apple Git-143)



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


end of thread, other threads:[~2026-02-24 16:13 UTC | newest]

Thread overview: 2+ 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]>
2026-02-24 16:13 New isolation test insert-conflict-do-update-4 outputs rows in alternative ordering Pavel Borisov <[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