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.94.2) (envelope-from ) id 1t5UyH-006VD1-Hz for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2024 19:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t5UyE-00997E-J8 for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Oct 2024 19:00: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.94.2) (envelope-from ) id 1t5UyE-009976-6f for pgsql-hackers@lists.postgresql.org; Mon, 28 Oct 2024 19:00:06 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t5UyC-003SnP-Ag for pgsql-hackers@lists.postgresql.org; Mon, 28 Oct 2024 19:00:05 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-539ee1acb86so4715866e87.0 for ; Mon, 28 Oct 2024 12:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730142003; x=1730746803; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uovo8+VK3yLy7Rt9zg4w1wIJg0cFYCA3kw771EMw3qE=; b=Vegq3a+pKTUsVz/dGzYoztGFzbmj1N1rfPJe7KtbdNmg1nqOa0cx2x27+xehgO+CXz 5m129SN6AWdA7dqApwWmFTKDMechErmRvo4fQE9+XZd8dbSybvHvHtjftaQqGWVDRZx7 Bwvyxvd+x1ncX2VmPSIMIdKu+91duWaj8wBnrNuNBs1kdfCNB/zbWjTR7I/zhe64PUCx gvBlOJ9N2X0ZfpTLAO3dbnDbUOeFj23dXIDtNmVPFH7qOc3bxRohOpWSMPU1GHrJkuul I34lxZ8jG2BswwvDEHqN3ztSJtTQN8WqcL6g9hGsPM5qRAEd08PyKy7iUtQJATk9dXln YJfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730142003; x=1730746803; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uovo8+VK3yLy7Rt9zg4w1wIJg0cFYCA3kw771EMw3qE=; b=fRluiG4auKzBctMPVEtZ8ZzPgtQizppVOz7skkYE4tkB+MdKzUDrNJAH0M7fyU/f8f ZpOsfptZwzrD4LfUCL5RLHxpxjfrUP3aFuwcBrMZB95QoXfV71VxxNiIDguHFh72tQDm JzHGJGqLU6G6lELyfNv/2lsNvY/i4Z0971n0vmKhppIB3IvieQFrHnh9nI8sZDfz/Xd6 lt80EwB5SAoj+iKDc+zu0G3fzHr+wsEvkZPr3pSuX0ptjyQYjMl6mktMLGAUEXNlyXuX EfvpdDwDf/hOBKk9Se8QNmwBRY7vvEkk4qA6GpcKTHLyfWuHWf9W6nGDBBKaWj6D9/iX 22Ug== X-Forwarded-Encrypted: i=1; AJvYcCXq5z7h4vonkgbrjt11AGJpxjRe9fcpQgaQerR4COywZVzpqIGHbyDkXN6v0Xhmg4ohsuOZRLWXoE9two8L@lists.postgresql.org X-Gm-Message-State: AOJu0YzKcf1tx2v991A2j174aeDpwyVezOBLRwx4ANBGrljxNjFIyl2U kW4MR8eywVAJY9cXhYVLu4hcNAfut4GQgV4hgNjkbZOf/ONjbf9R X-Google-Smtp-Source: AGHT+IEbRGJTx0CjYjHlAMoVMkC+VB/fuTKekVGhDijAZIajycEiTWtC/5CAOCC42utQe24+8ulwAg== X-Received: by 2002:a05:6512:3c95:b0:536:9f02:17b4 with SMTP id 2adb3069b0e04-53b3491cce4mr3973323e87.40.1730142002243; Mon, 28 Oct 2024 12:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.24.36]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53b2e1c9439sm1155433e87.200.2024.10.28.12.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Oct 2024 12:00:01 -0700 (PDT) Message-ID: Date: Mon, 28 Oct 2024 22:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR) Content-Language: en-US To: Tom Lane Cc: Andrew Dunstan , buildfarm@sraoss.co.jp, Pavel Stehule , Christoph Berg , Michael Banck , Tommy Pavlicek , =?UTF-8?Q?Dagfinn_Ilmari_Manns=c3=a5ker?= , pgsql-hackers@lists.postgresql.org, jian.universality@gmail.com References: <560086.1698160614@sss.pgh.pa.us> <570833.1698162135@sss.pgh.pa.us> <66f33840.050a0220.1f9e60.7fb9@mx.google.com> <325394.1727365907@sss.pgh.pa.us> <571930.1727454668@sss.pgh.pa.us> <621972.1727459684@sss.pgh.pa.us> <1092841.1727552736@sss.pgh.pa.us> <2245576.1728418678@sss.pgh.pa.us> <2864637.1728662904@sss.pgh.pa.us> <1967263.1729611423@sss.pgh.pa.us> <2480333.1729784872@sss.pgh.pa.us> <3792414.1730050914@sss.pgh.pa.us> <79284195-4993-7b00-f6df-8db28ca60fa3@gmail.co! m> <3975515.1730131606@sss.pgh.pa.us> From: Alexander Lakhin In-Reply-To: <3975515.1730131606@sss.pgh.pa.us> 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 28.10.2024 19:06, Tom Lane wrote: >> I've also dumped buf in read_whole_file() and found that in both >> PG_BINARY_R and "r" modes the 0d 0a ending is preserved. But it changed >> to 0a with the "rt" mode (see [1]), and it makes the test (and the whole >> `meson test`) pass for me. > Interesting. I believe we decided years ago that we didn't need to > use "rt" mode because that was the default on Windows, but was that > a misreading of the documentation? The link you provided doesn't > give any hint that there are more than two behaviors. > > However ... the link you provided also mentions that text mode > includes treating control-Z as EOF; which I'd forgotten, but it > does make it less safe than I thought to use text mode for > reading script files. I think that this other behavior can be explained by pgwin32_fopen()/ pgwin32_open() coding (O_TEXT assumed implicitly only #ifdef FRONTEND). Anyway, as you noticed, \x1A injected into test_ext....sql really leads to the file contents truncation on read (with "rt"), so I agree that using the text/translation mode here is not an improvement. > What I'm now thinking is that we should revert 924e03917 after > all (that is, go back to using PG_BINARY_R) and instead make > read_whole_file manually squash \r\n to \n if we're on Windows. > Ugly, but I have yet to find anything about that platform that > isn't. Yes, I think this should help. Best regards, Alexander