Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hi2pS-0006IB-GS for pgsql-general@arkaria.postgresql.org; Mon, 01 Jul 2019 20:23:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hi2pR-00031Q-BW for pgsql-general@arkaria.postgresql.org; Mon, 01 Jul 2019 20:23:09 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hi2pR-00031H-1y for pgsql-general@lists.postgresql.org; Mon, 01 Jul 2019 20:23:09 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hi2pK-0002X1-Nn for pgsql-general@lists.postgresql.org; Mon, 01 Jul 2019 20:23:08 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5E69A21F4C; Mon, 1 Jul 2019 16:23:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 01 Jul 2019 16:23:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=3 VPqVPhAYlK7poLISCuRY7UycH/jEnxTqBBKaLiIj9s=; b=RjGLgPZbyTZFERXDe DOgGgzGtspyOJc6OxDwQ9w8tpf5D4vNrfzfXy/gCA/+BdqA4pPF843V+4QA1jq9b AKrX1uQEUrMpjIZ3fEaWRMk/cL/Ip2H39FSVinVGdDVyljTlQP7Lr6je1p9BUjl3 UroPIidy4K4wUnR+E77ju3nvTG9TEcwaVoAhiKU8TougPYh4vukWTmo0SbGWE1Xq vFI/gdzBVw/PuYYz+s2aF3ARHz6HwSuUAVY2YZlFK21YWppzJAH834T6ymtFjNHU dov9SuMSKbO0Xs53N/gr5uvnUVu22nMQzBLLN98xpCvwAdyBtH+3yhYimtl70EDz gvX7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=3VPqVPhAYlK7poLISCuRY7UycH/jEnxTqBBKaLiIj 9s=; b=nvVX60unyP1Ewf1ggT0//1aF2Qie/cgxF20y+tYKaxHeP093NEVY9FDQD +tnb0RK4AOPvdPSzZGFMXlmCPGFY5KD9o9andckYwBDYvPOHqH7qwhh3Ea9A9Aut 1yaiMBNIPN7Azv0rh2tPV718j6dXltpl3ONYHaivkV3Yh8E3poa+NZKdj1ZkfTzr foyNXaxALYXBUpmJj6qoVX92HrAEWCSYiak3fOzLWEAq7AvZMR5HA6SSbHV0CBiz ORyE8NtdRuE4zOdA+cIQbbbKjLxghD516/v1isvWeuucoKhPoCQlGMDviQyJICuT zF0voXpA+d8+6wKXAYCShiNz/evug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrvdeigddugeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrdduhedtrddvtddvnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 710468005C; Mon, 1 Jul 2019 16:23:00 -0400 (EDT) Subject: Re: Argument casting hierarchy? To: Wells Oliver Cc: pgsql-general@lists.postgresql.org References: <62454612-6eed-de1e-45a6-23943b42d82d@aklaver.com> From: Adrian Klaver Message-ID: <541ea689-9aa2-30c5-f504-441bb85bbe26@aklaver.com> Date: Mon, 1 Jul 2019 13:22:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/1/19 1:18 PM, Wells Oliver wrote: > What is it you're showing me exactly? The valid numeric types accepted > (and cast) by both real and numerics? That there is builtin casting for a source of either float4 or numeric to the types listed respectively and that numeric offers more choices. Might help you decide on which type you want to use for a single function. > > On Mon, Jul 1, 2019 at 1:15 PM Adrian Klaver > wrote: > > On 7/1/19 12:18 PM, Wells Oliver wrote: > > Hi guys, hoping you can help clarify what the 'hierarchy' of > casts might > > be in function arguments. > > > > Meaning I have the following two functions > > > > stats.foo1 (a bigint, b bigint) returns a/b::numeric > > > > stats.foo1 (a real, b real) returns a/b::numeric > > > > It's essentially the same function, but I thought I had to create > two to > > accept the different types. > > > > However, when I call stats.foo1(3::smallint, 4::smallint) I > receive the old: > > > > ERROR:  function stats.foo(smallint, smallint) is not unique > > > > Along w/ the message to explicitly cast. > > > > I am essentially trying to write one function that will cast > "down", I > > guess, anything smaller than what's passed. I am guessing I only > need > > the real/real argument signature, but I wanted some clarity from > the group. > >  From the system catalogs, where float4 = real: > > select typname AS cast_target  from pg_cast join pg_type on > pg_cast.casttarget = pg_type.oid  where castsource = 'float4'::regtype; >   cast_target > ------------- >   int8 >   int2 >   int4 >   float8 >   numeric > > select typname AS cast_target  from pg_cast join pg_type on > pg_cast.casttarget = pg_type.oid  where castsource = 'numeric'::regtype; >   cast_target > ------------- >   int8 >   int2 >   int4 >   float4 >   float8 >   money >   numeric > (7 rows) > > > > > > > I appreciate it. > > > > -- > > Wells Oliver > > wells.oliver@gmail.com > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > > > -- > Wells Oliver > wells.oliver@gmail.com -- Adrian Klaver adrian.klaver@aklaver.com