Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1esbKu-00060d-2y for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 21:38:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1esbKs-0003Sy-17 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 21:38:26 +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.89) (envelope-from ) id 1esbKr-0003So-Lz for pgsql-hackers@lists.postgresql.org; Sun, 04 Mar 2018 21:38:25 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1esbKj-0005Zd-9B for pgsql-hackers@postgresql.org; Sun, 04 Mar 2018 21:38:24 +0000 Received: by mail-wm0-x243.google.com with SMTP id x7so11955893wmc.0 for ; Sun, 04 Mar 2018 13:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zSTsJmHaJHSkDdoRzpE4BbcZOeII6kzq5DO4X7ri0C8=; b=U+NXWKGMylqhAiJelSnqVfJoduqTKF16SkIQQTu93rpU4jkq0PK5zYj4wFnrx3gaYD RRcltWrdJPxGcARczFmnW2eo6gWTORTzFNE2rBv4Q2Tt0U25mzK175kb78PkrXus4pJz 2BcIFfaBsscRta7ZjqVOzvTXyNelWWqSNzeoNNib4lW3ifpnc0CyTtxlrMX6URBBoLDg zmCyRhJgkc2sl9bjO/ZxLjlKoy1D3cLCR9PEVUe3oA7BrVQcwZwOHAenRPE9MD2FViMi CtrXBQxoMu56NhKa/GqxcEO5x7jukOtt2csPP7eo6gCub0iS//UcBd3FhkLxuKW1+knF qtag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zSTsJmHaJHSkDdoRzpE4BbcZOeII6kzq5DO4X7ri0C8=; b=F+wdaEzbsvvZ32klwcjX/5nnMHq4QhwXt8AWW5NFMCoEYb7Hferwu6Zderf1oFgeA0 QJ1BGzvXw9KqrrCSj7Q72Et9gwr0bEc9RoZmyyHCkDN0ZIBrP5EjciFOxN5oPvUof+Ag OaR0xga+ffG5gHYWmhNOSHa23rflgGWB3uWXwa5tmLigRZhf86Lke9DZWkaXa8jzCTlo X9Zk5KsIQd5Ofvr+e9orORLXuiSg5+nu/50g3QMNTa5EpVCsBWuBucw2T3vxDc/aXS7T ujx4V8rh01dUHXONDq9QZtAwTp+S/jIKk176mPMGdhhpJ+9wZeCQeRpez0nLqULJiwML BK2w== X-Gm-Message-State: AElRT7H3h5c6y6aXzskR2M2x7//mDBuS/PXkgtmKIev+UDNrvTCLL76f 20FY7ekHaTCmdX8zuIcK3QRhulotkq4soGCAMSaCjClyNagb9RZfftgyJdUu6hjmu7quF5BsJPc NZAXHUKpRDKaEzXJcx8xxPtVZ6yCjJPN03kaOF6Y406KcoWuud8zw2TsoJcsAGklYo+RwOvyMJQ Wjjb56/U2n X-Google-Smtp-Source: AG47ELs/4hj8yDiZN/wRhF5E+hvZgVB5AsAlGL2GjAK0pBh9IqqKQq/t+Jnn7DPuvjvb1FYl+jMr5A== X-Received: by 10.28.191.138 with SMTP id o10mr1788923wmi.26.1520199495193; Sun, 04 Mar 2018 13:38:15 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id d8sm11852415wrf.8.2018.03.04.13.38.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Mar 2018 13:38:14 -0800 (PST) Subject: Re: [HACKERS] user-defined numeric data types triggering ERROR: unsupported type To: Tom Lane Cc: PostgreSQL-development References: <9389.1506003842@sss.pgh.pa.us> <4b444362-4240-49e0-3523-724e5932b060@2ndquadrant.com> <24767.1506180446@sss.pgh.pa.us> <14597.1520038563@sss.pgh.pa.us> <42f4e37e-f923-6ea9-4172-cdec5a8c2d25@2ndquadrant.com> <11916.1520127473@sss.pgh.pa.us> <82f29126-df5a-d4bc-f5b5-47233e29aaa6@2ndquadrant.com> <15879.1520182782@sss.pgh.pa.us> <07b0dcd6-45f7-a2d3-99c6-115490b2cc98@2ndquadrant.com> <25629.1520192235@sss.pgh.pa.us> <29012.1520196416@sss.pgh.pa.us> From: Tomas Vondra Message-ID: Date: Sun, 4 Mar 2018 22:38:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <29012.1520196416@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/04/2018 09:46 PM, Tom Lane wrote: > Tomas Vondra writes: >> On 03/04/2018 08:37 PM, Tom Lane wrote: >>> Oh, well, that was another problem I had with it: those tests do basically >>> nothing to ensure that we won't add another such problem in the future. > >> I don't follow. How would adding new custom types break the checks? If >> someone adds a new type along with operators for comparing it with the >> built-in types (supported by convert_to_scalar), then surely it would >> hit a code path tested by those tests. > > Well, I think the existing bytea bug is a counterexample to that. If > someone were to repeat that mistake with, say, UUID, these tests would not > catch it, because none of them would exercise UUID-vs-something-else. > For that matter, your statement is false on its face, because even if > somebody tried to add say uuid-versus-int8, these tests would not catch > lack of support for that in convert_to_scalar unless the specific case of > uuid-versus-int8 were added to the tests. > I suspect we're simply having different expectations what the tests could/should protect against - my intention was to make sure someone does not break convert_to_scalar for the currently handled types. So for example if someone adds the uuid-versus-int8 operator you mention, then int8_var > '55e65ca2-4136-4a4b-ba78-cd3fe4678203'::uuid simply returns false because convert_to_scalar does not handle UUIDs yet (and you're right none of the tests enforces it), while uuid_var > 123456::int8 is handled by the NUMERICOID case, and convert_numeric_to_scalar returns failure=true. And this is already checked by one of the tests. If someone adds UUID handling into convert_to_scalar, that would need to include a bunch of new tests, of course. One reason why I wanted to include the tests was that we've been talking about reworking this code to allow custom conversion routines etc. In which case being able to verify the behavior stays the same is quite valuable, I think. >> So perhaps the best thing we can do is documenting this in the comment >> before convert_to_scalar? > > I already updated the comment inside it ... > Oh, right. Sorry, I missed that somehow. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services