Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpTK1-009F9D-0p for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 15:37:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpTJy-00BDBc-2N for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 15:37:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpTJy-00BDBT-1H for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 15:37:06 +0000 Received: from mail-dy1-x132e.google.com ([2607:f8b0:4864:20::132e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpTJv-00000001puD-2m7i for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 15:37:05 +0000 Received: by mail-dy1-x132e.google.com with SMTP id 5a478bee46e88-2b86671f87eso848811eec.0 for ; Mon, 09 Feb 2026 07:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770651421; x=1771256221; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tPs+xg40EEf1vAbLpeHPX2b1yD6WIG0LI1XLtvv7K7Y=; b=MqVC30CFGDuSgLG5foRXJIvU3s48dXJlXQltHX8n/vDvyZdxhJi3LqIOEgKPqTKSeK ULtioTli6MFBCWEAL/k3/C6BhKVRbPv/lfP5+ewK8tDvaWXjCU1HDnpZn5+i1+9iBQnA 3KbTcGSHtYlw0cb/XQu5mnSLThsQRHMkpSRswKdFwNih0ZEi8wJRrUHwurpdFDE78xw4 Sm5rm/t61dzdMQOJO4yIVJAC03fWoIvVnhKyKhgjDeDUt3OcohTyEUzo0kJU0zxa3UtI SZLjuc5b8VfbX+/8L/2tfpVJYQA2M0PKN+1HljbL5bQ+yxBKfs8ibCTMQqP0GsDzAxo8 InFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770651421; x=1771256221; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tPs+xg40EEf1vAbLpeHPX2b1yD6WIG0LI1XLtvv7K7Y=; b=OQjQiwu572PF/Vc9AN2RYV9rdJte3sCco8SDd7lO236Uqq69cpUG8kWmnG51iFsCPy LJ0mpRHQakuTyJ99CNe64SdZKm+anOwVHGy2xEb+NJal47TxGy4ezCUAkjFoSaYSXQi6 GOH1NqAv2D8A0y2r/9xJ9OtVL/21twOwgi1a2BTN9i3p+sy3yPWNr4ZrqloNJLoNnuwT wa+s2mIxhQlvmoA8FJMUHrYFucXwzvoajyUjBUEo6Tovne/Jp0AcIEAFbQ1pHLFMfeuA vTNa36yVxX2erjEkQZfpMMhwazQGPFL6JKZkz/dHt2iVLL+mj3CIaY+JXdLpRmy/mP5O o8KQ== X-Forwarded-Encrypted: i=1; AJvYcCW48eksQVM0p+cxp4dnD55p6ET19EivyzjgYlrFQzKdSCRZPyGPWdb8q7Zb0oBApWPthoo+p4HCW9o6WDId@lists.postgresql.org X-Gm-Message-State: AOJu0YygURF2XsTtZWuKewsDkLcaTgwoFlp2obiXGDj53XecNAOSP44E 0+ht4iDemuJVtuM20zzPHU85+nn0ExwiBoXWRR+zxLX+Jhp3tNUkUKMY X-Gm-Gg: AZuq6aLU0YhaTjkLaFdoYqW1PQ0BvUxM83lvJSj6NXAYF3b70Y3ijl5muN1xfoHPDPa kWXVm2/+oSDwFmfsB7YjbVsQpMzOXBzfM1JjhNuI5vFLhzMSWI6N+MSaxOPBSle4nLms7ZCsFzZ 2BKPo50+0VsMjZ////8cQnxlZOZ9+Gt+fYzyFHLkkLyP3LDORijSoVYrxCAJ1paXE/COBVK7Ybt JaxT/51a7t4Dh6OFKoWhM9DmExuuQOHPM2X/TTZDiaySvILLz9b4aVYgZkEu8gi+tcW3bSOV8uN FCNPhBo8LL7kUEfhfMimWP75yADTwOA9rNRsW1tsepOtFR0AKqtyOGTipmXPISrpClJ8yKadjSO mEGem4y1YrafREHw24+Y3Ta78EDNDczUenGBZu/qByumMAYZMJa3OeiXQ+s2hCTx68JnnpqcqUk AHMgDXJU8CYIGtYvUeuCuc8NpbkuutuT16ZtYCZcMbvgAbnm2VKQVahbEGRf9nKp+uz8xAV+hVy C8VPCrl9Q== X-Received: by 2002:a05:7301:2b87:b0:2b7:2f29:648c with SMTP id 5a478bee46e88-2b85642af45mr5280645eec.8.1770651420471; Mon, 09 Feb 2026 07:37:00 -0800 (PST) Received: from ?IPV6:2804:14d:328a:a59c:75c0:b9c8:6e13:3565? ([2804:14d:328a:a59c:75c0:b9c8:6e13:3565]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ba776c4a2bsm1598425eec.24.2026.02.09.07.36.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Feb 2026 07:36:59 -0800 (PST) Message-ID: <976f11ca-ea15-47b4-a0cc-8828f12e35ec@gmail.com> Date: Mon, 9 Feb 2026 12:36:55 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row To: jian he Cc: torikoshia , Masahiko Sawada , vignesh C , Jim Jones , Kirill Reshke , Fujii Masao , "David G. Johnston" , Yugo NAGATA , PostgreSQL Hackers References: <901967e5-e5dc-42c6-b2bf-fb3a49d7e787@gmail.com> <4c540fe3-495c-4bbf-8dcf-2c1e2b88bc3d@gmail.com> Content-Language: en-US From: Matheus Alcantara In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 09/02/26 00:59, jian he wrote: >> Thanks, overall the patch looks good to me. I'm attaching a diff with >> just some small tweaks on documentation and error messages. Please see >> and check if it's make sense. >> > In the function CopyFrom, we have: > if (cstate->opts.on_error == COPY_ON_ERROR_IGNORE && > cstate->escontext->error_occurred) > { > cstate->escontext->error_occurred = false; > pgstat_progress_update_param(PROGRESS_COPY_TUPLES_SKIPPED, > cstate->num_errors); > > That means PROGRESS_COPY_TUPLES_SKIPPED applied for COPY_ON_ERROR_IGNORE only. > So > > Number of tuples skipped because they contain malformed data. > This counter only advances when > ignore is specified to the ON_ERROR > option. > > should be ok. > Ok, agree. >> I'm wondering if we should have an else if block on >> CopyFromTextLikeOneRow() when cstate->cur_attval is NULL to handle >> COPY_ON_ERROR_SET_NULL when log_verbosity is set to >> COPY_LOG_VERBOSITY_VERBOSE >> >> if (cstate->opts.on_error == COPY_ON_ERROR_IGNORE) >> ereport(NOTICE, >> errmsg("skipping row due to data type incompatibility at line %" PRIu64 " for column \"%s\": null input", >> cstate->cur_lineno, >> cstate->cur_attname)); >> + else if (cstate->opts.on_error == COPY_ON_ERROR_SET_NULL) >> + ereport(NOTICE, >> + errmsg("setting to null due to data type incompatibility at line %" PRIu64 " for column \"%s\": null input", >> + cstate->cur_lineno, >> + cstate->cur_attname)); >> > > CopyFromTextLikeOneRow, we have: > cstate->cur_attname = NameStr(att->attname); > cstate->cur_attval = string; > > even if "string" is NULL (two InputFunctionCallSafe function call with > "str" value as NULL), it will fail at > ``` > else if (string == NULL) > ereport(ERROR, > errcode(ERRCODE_NOT_NULL_VIOLATION), > errmsg("null value in column \"%s\" > violates not-null constraint of domain %s", > cstate->cur_attname, > format_type_be(typioparams[m])), > errdatatype(typioparams[m])); > ``` > so i think condition like: > if (cstate->opts.log_verbosity == COPY_LOG_VERBOSITY_VERBOSE && > cstate->cur_attval == NULL && > cstate->opts.on_error == COPY_ON_ERROR_SET_NULL) > is not reachable. > therefore I didn't add the ELSE IF block. > Ok, make sense. I've tested and it seems correct. > inspired by your change, I further simplified the error handling code. > Thanks for the new version. It looks good to me. I don't have any other comments. -- Matheus Alcantara EDB: https://www.enterprisedb.com