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 1hi2ic-00065R-Nt for pgsql-general@arkaria.postgresql.org; Mon, 01 Jul 2019 20:16:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hi2ib-0005b1-Ju for pgsql-general@arkaria.postgresql.org; Mon, 01 Jul 2019 20:16:05 +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 1hi2ib-0005au-AQ for pgsql-general@lists.postgresql.org; Mon, 01 Jul 2019 20:16:05 +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 1hi2iW-0002S0-Nd for pgsql-general@lists.postgresql.org; Mon, 01 Jul 2019 20:16:04 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1EDD4220B8; Mon, 1 Jul 2019 16:15:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 01 Jul 2019 16:15:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=L gFxNKL9doB/2rEACCB/tT3Y+W5kEEnxjdKy0995yt0=; b=XQiQobpxdLSorsISI +8hpCSoDtPKTt3EwZJV30WtwfdcLHh9tLhBddMPG+6tE86Kj63/yOcxDQz5f4iQw jPDRWXcTEqTFtFzE2D/2cml4ahHQ/70kI6sYRPBi+qqhdFBYAoUxjSsTYw6pV8+7 zQCyxvRKiY4BYYYjNKTJDBFE7T7GYKChoGxem0lQQzP4J2pBod5RVA6Jhlz88mGi Cvk4rcJIp31braNgNYuJRHutx4lXz2mR3E+YO3ILqiuriD+UidYvAnvDlIfJf+AI cUdf7qrUuIEXSrLPW6Ufyu4Pn+/oSKGrzC108DusiFZuYYbO6v4GUhRJRuQhiOgY ed+jQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=LgFxNKL9doB/2rEACCB/tT3Y+W5kEEnxjdKy0995y t0=; b=LyCI79rnRgVz9GJ50LDirZDIKWvmANg3TUroDaDJyJIr6gmPlkj+AYxl1 g4JL+B7Nshqu9VrI1+P9ASt2ot2beSCRK6IEaovQd+HhfiJ+XpQtU5AA/7cHyReH biDDQTkq0lIqyLagsAlCeZessTU98Sjz8Tcjc/RMF1+RtY+i8QsN8bcC12LekERQ fAMh0M0isZVKB5B06wuhXdP4a0UZxCAt/A5VofImqrujdGj2Sfpb94VZ0U/sGB0S D2eeaJsP80fiQNYX8qaFw8EfyuRLVxDjNT90Url6RKQ2MKnmIp/9OKjCzwLpZj4g Gmr4KI3yTyMZhMvLvMf9LRAaFKUhg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrvdeigddugeekucetufdoteggodetrfdotf 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 5A12980062; Mon, 1 Jul 2019 16:15:39 -0400 (EDT) Subject: Re: Argument casting hierarchy? To: Wells Oliver , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <62454612-6eed-de1e-45a6-23943b42d82d@aklaver.com> Date: Mon, 1 Jul 2019 13:15:38 -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 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