pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Koval <d.koval@postgrespro.ru>
To: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17288: PSQL bug with COPY command (Windows)
Date: Fri, 19 Nov 2021 15:27:34 +0300
Message-ID: <e68b6e05-ee89-26ef-b25d-04bc0ae45396@postgrespro.ru> (raw)
In-Reply-To: <CAC+AXB1FTZueNdvT1F4fpr4z9gxpcKkgWa-Awor9XC9PAKLVSA@mail.gmail.com>
References: <17288-6b58a91025a8a8a3@postgresql.org>
	<b95273fb-a51a-d0a9-e4a8-501e32e204e5@postgrespro.ru>
	<YZYDZwDtw/Ioojb4@paquier.xyz>
	<9e4efe29-0ff9-0808-fe32-d1d50e0be4fa@postgrespro.ru>
	<CAC+AXB3BKByL8O39qARu3XYMWmrNqMWhcHZZ_2ygqvrK-W6O1g@mail.gmail.com>
	<fe1cde9e-1e52-4f24-3ff7-d01f28a63790@postgrespro.ru>
	<YZdK6DjbtCT7rz9S@paquier.xyz>
	<4c22d38f-efa9-4d83-c551-707f1770e585@postgrespro.ru>
	<CAC+AXB1C1C_z3XQR=ZxiG+V0U9RDJFtJJamvYMoq+d4RoVRh4A@mail.gmail.com>
	<9caa0612-19e5-f860-4b97-908a1c721233@postgrespro.ru>
	<CAC+AXB1FTZueNdvT1F4fpr4z9gxpcKkgWa-Awor9XC9PAKLVSA@mail.gmail.com>

 >GetFinalPathNameByHandleA() is slower when there is redirection, when
 >there is no redirection it's similar or faster than
 >GetFileInformationByHandle(), and that should be the most common case.

I tested 2 cases:

1) "stdout" is not redirected.
In this case GetFinalPathNameByHandleA() returns error and 
GetFileInformationByHandle() returns error.
Simple test in attachment.
---
Result:
GetFileInformationByHandle: 7, GetFinalPathNameByHandleA: 16

2) "stdout" redirected (need to uncomment 2 lines in test).
Both function works without error.
---
Result (see file "1.txt"):
GetFileInformationByHandle: 34, GetFinalPathNameByHandleA: 120

The difference is not very big, but it is.

With best regards,
Dmitry.

Attachments:

test2.c (text/plain, 676B) download #include <windows.h> #include <stdio.h> #include <io.h> #include <time.h> int main() { int i; clock_t t1, t2, t3; HANDLE hFile; BY_HANDLE_FILE_INFORMATION fiData; char path[MAX_PATH]; //FILE* stream; //freopen_s(&stream, "1.txt", "a", stdout); hFile = (HANDLE)_get_osfhandle(_fileno(stdout)); t1 = clock(); for (i = 0; i < 10000; i++) GetFileInformationByHandle(hFile, &fiData); t2 = clock(); for (i = 0; i < 10000; i++) GetFinalPathNameByHandleA(hFile, path, MAX_PATH, VOLUME_NAME_NT); t3 = clock(); printf("GetFileInformationByHandle: %d, " "GetFinalPathNameByHandleA: %d\n", t2 - t1, t3 - t2); return 0; }

view thread (29+ messages)  latest in thread

Message-ID: <e68b6e05-ee89-26ef-b25d-04bc0ae45396@postgrespro.ru>
Permalink:  ../e68b6e05-ee89-26ef-b25d-04bc0ae45396@postgrespro.ru/
Also on:    postgresql.org/message-id/e68b6e05-ee89-26ef-b25d-04bc0ae45396@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: d.koval@postgrespro.ru, juanjo.santamaria@gmail.com, michael@paquier.xyz, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17288: PSQL bug with COPY command (Windows)
  In-Reply-To: <e68b6e05-ee89-26ef-b25d-04bc0ae45396@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox