Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFVkk-0003WN-U0 for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Feb 2022 06:37:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nFVkj-0005m0-Pr for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Feb 2022 06:37:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFVki-0005lr-KZ for pgsql-hackers@lists.postgresql.org; Thu, 03 Feb 2022 06:37:57 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nFVkd-00072G-9u for pgsql-hackers@postgresql.org; Thu, 03 Feb 2022 06:37:55 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id A1A225C0078; Thu, 3 Feb 2022 01:37:48 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 03 Feb 2022 01:37:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=BTKOs/LbqrrbHqkuQhIdWXb4W6inJ3qkzY6/h6IJS qc=; b=D3mX12fja/0na4MV0nXvrmeNNL6wOfNJ/6LZS5NIxgLR3GflUiquGtNFO 3QeAqX0mtpFH7h7/34QLpzjo2mILmBzqRw10tHBLGRNjqOBGPbRVXbRNqJHAkhlD Ew5cd+EiFy27I5vvsxAWWxtsjnCb+QONXXImqMNWaP4sp8aH/HJuqV0Yhoo/Epm8 tXe4yqiXINkXPMPix+lAlbFr27mN0/lgiWNCvs0mn43n1oAsHTOZUurCsABueMHh 4+OPc98I6l8X5xVhbn+D9ustwY0mYxwvPdgZ0kG2Uao2aLYtCJv8hP1LsniVo1Vs PmRIjaCJQZoWWkcC4Wib9EtA02aGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrgeeigdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuhffvfhgjtgfgsehtkeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeefgefgteefudehheduffev lefhkeeulefhfffgvdelgfffueduledtgfekiefhjeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Feb 2022 01:37:46 -0500 (EST) Message-ID: <8eba1968-9503-5be7-b473-37383f17bb72@enterprisedb.com> Date: Thu, 3 Feb 2022 07:37:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: Add header support to text format and matching feature Content-Language: en-US From: Peter Eisentraut To: =?UTF-8?Q?R=c3=a9mi_Lapeyre?= Cc: Zhihong Yu , David Steele , Michael Paquier , vignesh C , PostgreSQL-development , Daniel Verite References: <018819f7-6cbe-4f20-903f-de1b9e434119@manitou-mail.org> <9B3E4BEB-F6E2-4D4D-AFB8-58FB3957EB35@lenstra.fr> <29be62a4-e931-b745-3e24-7aa111963447@pgmasters.net> <8A231E8D-4491-4DC2-AF72-EBEAEF0F0967@lenstra.fr> <683DD77E-38B3-4BC2-810E-4122C7A5A053@lenstra.fr> <8964EEB0-7AE1-4549-BA4C-119EF8CD266C@lenstra.fr> <94FDDB44-A608-4C75-A733-9F8FC5180D6B@lenstra.fr> <4816b2df-646f-dc19-e5cc-4bfbd04c0e43@enterprisedb.com> <07891B9D-2140-4C06-AF96-C14F1E1B0E8E@lenstra.fr> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 31.01.22 07:54, Peter Eisentraut wrote: > On 30.01.22 23:56, Rémi Lapeyre wrote: >>> I notice in the 0002 patch that there is no test case for the error >>> "wrong header for column \"%s\": got \"%s\"", which I think is really >>> the core functionality of this patch.  So please add that. >>> >> >> I added a test for it in this new version of the patch. > > The file_fdw.sql tests contain this > > +CREATE FOREIGN TABLE header_doesnt_match (a int, foo text) SERVER > file_server > +OPTIONS (format 'csv', filename :'filename', delimiter ',', header > 'match');   -- ERROR > > but no actual error is generated.  Please review the additions on the > file_fdw tests to see that they make sense. A few more comments on your latest patch: - The DefGetCopyHeader() function seems very bulky and might not be necessary. I think you can just check for the string "match" first and then use defGetBoolean() as before if it didn't match. - If you define COPY_HEADER_ABSENT = 0 in the enum, then most of the existing truth checks don't need to be changed. - In NextCopyFromRawFields(), it looks like you have code that replaces the null_print value if the supplied column name is null. I don't think we should allow null column values. Someone, this should be an error. (Do we use null_print on output and make the column name null if it matches?)