Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dW0K8-0004D3-0J for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Jul 2017 13:08:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dW0K7-0002wA-JF for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Jul 2017 13:07:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dW0K7-0002vy-8f; Fri, 14 Jul 2017 13:07:59 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dW0K3-0000ar-9F; Fri, 14 Jul 2017 13:07:58 +0000 Received: by mail-lf0-x243.google.com with SMTP id t72so8137506lff.0; Fri, 14 Jul 2017 06:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=Ui1vaPL3++tIDBn+f/Ni4JqesuXIdFW8L5dFYi4+QD4=; b=ClMBDpXvDb5Thav3pUEVKBUvRq5vJkhR9/YdHD95Qwd8EYXV3K/Ytq3ryDKzpEfaoY xienGWn2AFGWpDf1okqNMf6a65/0ZjimE/yPPkNrV+5DUc89CIVwI805WaR9zLAm2tgg ud4A65v/KE45MvNGKsWemGQm0jdrMuabHSsS/5KQzZ0XFeaMy4yxJDXynPI+q/yOzf2i ytcFEgzxiJp79p5fttyXE3oiPzbSSvoGL3wGRZm2T0WVnDU9cVxZVWTx/RICiMfmM4oL KZ1k9wO5RpoLPBMmZdF9zQk44ef9Dv1HqYu9C8DmdymmQzBVA6Wh+AVPlewzAbtkm8By RKGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Ui1vaPL3++tIDBn+f/Ni4JqesuXIdFW8L5dFYi4+QD4=; b=HEt232WEuvaQAawiDtglx8a2Z2jPsMjj6WLIjcA+fbHPjp52uLGDASzItAmnle9QXV 3uUCXYmCZu01pYXZzOFb4z+lP9tB2DNrB9et0wYMOGDfNNqHzpIpn97YRhBRfc0Na3xg oYnQg8xcRoBCRo9npISlObsYBM/ZYoXFur/e6+RpStBPYXli/lDKz4pNOVzvSiMDqCwS FqxwDrMydO/potJra48bMBsvW8J6kUXe7KCdQIZ0TxSKdBB9JJCKQKlvSgMt/JyliHEO 7XyVYKh7HDNF62d0eed/6pLzFgWNCwncE08ocAteuPj6SDZn8fQE7epJogH9MHbiOkl0 pblQ== X-Gm-Message-State: AIVw110VYFzrWgALomaGVUx4F3i6NkNzW6cS/WvGefXtQfzbN5WkLUt4 0UgOKpnj9hqOQLDc X-Received: by 10.46.32.227 with SMTP id g96mr901093lji.138.1500037673992; Fri, 14 Jul 2017 06:07:53 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibng32-54fb4e-103.dhcp.inet.fi. [84.251.78.103]) by smtp.gmail.com with ESMTPSA id r7sm1996803lfe.38.2017.07.14.06.07.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 06:07:52 -0700 (PDT) Subject: Re: BUG #14634: On Windows pg_basebackup should write tar to stdout in binary mode To: Haribabu Kommi References: <20170428082818.24366.13134@wrigleys.postgresql.org> <931e755b-02df-d504-e5ad-eaeaa6ab9cd3@iki.fi> Cc: henry_boehlert@agilent.com, "pgsql-bugs@postgresql.org" , "pgsql-hackers@postgresql.org" From: Heikki Linnakangas Message-ID: <49d09912-6ad5-ddac-24a7-e7d4b8139a3e@iki.fi> Date: Fri, 14 Jul 2017 16:07:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 07/14/2017 05:27 AM, Haribabu Kommi wrote: > On Fri, Jul 14, 2017 at 2:54 AM, Heikki Linnakangas wrote: > >> On 05/03/2017 07:32 AM, Haribabu Kommi wrote: >> >>> [Adding -hackers mailing list] >>> >>> On Fri, Apr 28, 2017 at 6:28 PM, wrote: >>> >>>> Executing command pg_basebackup -D -F t writes its output to stdout, >>>> which >>>> is open in text mode, causing LF to be converted to CR LF thus corrupting >>>> the resulting archive. >>>> >>>> To write the tar to stdout, on Windows stdout's mode should be >>>> temporarily >>>> switched to binary. >>>> >>>> https://msdn.microsoft.com/en-us/library/tw4k6df8.aspx >>> >>> Thanks for reporting the issue. >>> With the attached patch, I was able to extract the tar file that gets >>> generated when the tar file is written into stdout. I tested the >>> the compressed tar also. >>> >>> This bug needs to be fixed in back branches also. >> >> Seems reasonable. One question: >> >> In the patch, you used "_setmode" function, while the calls in >> src/bin/pg_dump/pg_backup_archiver.c use "setmode". There are a few >> places in the backend that also use "_setmode". What's the difference? >> Should we change some of them to be consistent? > > Actually there is no functional difference between these two functions. > one is a POSIX variant and another one is ISO C++ variant [1]. The support > of POSIX variant is deprecated in windows, because of this reason we should > use the _setmode instead of setmode. > > I attached the patch to change the pg_dump code to use _setmode function > instead of _setmode to be consistent with other functions. Ok, committed and backpatched both patches. Thanks! - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs