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.92) (envelope-from ) id 1jBPjl-0006xX-1U for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2020 21:14:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBPjj-0004LW-HL for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2020 21:14:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jBPjj-0004LE-53 for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2020 21:14:55 +0000 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jBPjc-0000KV-C5 for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2020 21:14:53 +0000 Received: by mail-qk1-x731.google.com with SMTP id f3so10802601qkh.1 for ; Mon, 09 Mar 2020 14:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=D8kz4ssJGn+L6w2jLHddFRAZmGnrvb2IOZHhtmW1nRc=; b=ezZSa2+EYwn03B0VtboFhoPxpK8aKCpSNtUpYcU0PmrEvwJE9dGRgPR9ziTqnQe3j4 ZlOYUMHkzO+iTkUhfXFvMODgIeumDM8zfhf2k7DRvC3sgtyV2vMC78e2vQh+f9YczNOn /V6n5/lnahy/ERm58dXWHmrm+CfaIEfbTXYF1HH13RPN0+ncRvmFmx2cxIsadxveYM3x Nub7mFVOKlmFUMBZt1hXnKJgSRJq6/TR97WZKTj6pMUeRDg1tjvNN+LpYA43wU7wrVLN iyw017L96QZKMw/R58l+g163VlrZOzvrBEG9TxFX65CTq8KIc/KQvOGjD3409eqGEOJF 5tcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=D8kz4ssJGn+L6w2jLHddFRAZmGnrvb2IOZHhtmW1nRc=; b=oE/r+4DE+/KC/HNafe2w5BoC6Z4HmJ5aGEHyfHfy//NcMIUQmIMxP+sW7s6KohWUZn iy7hgtC9htF+/87QWw589eEM3QY6DVKnTDnDbVtZyOqKdD0eiF6Gs0HG14fnLKk5yscG HMjgsj3jMc0kFkQgm7PF5/El5oTKmVG/58n1YPBX82luroiMiDCsJg17tHtGMjrgGGEV jh41YdEZMvETWkL75jS/Dia0P5B1bVDkBAwXOp/LKlvtz1YFMvH26vu/SlWUQs261Xnw leveTTdU0dJi5LEMCfw0x13bqUmAhakeO+tUcIkY2Dd9T7N5awA4YTCp/dTGr+awMWmd GT3Q== X-Gm-Message-State: ANhLgQ04b59O1to+x6MAJ1Eqo7LJ+7DzbOP3tEQk/JH/5ETTL3JV1Nhr iLdiM8vrw18dC7sUhKLPnnNDU39M9cyTQdeeyfouLLQjRDtxkfvWsfKthPph4eYt7Ujw/IJlNy9 mgSsCQICeu6bgHCjIJ90TUDdDnQjCAClOR1ojJH99SG8H0vRL++qOVde+L9tD1HOhX2yTMgfw2K 9Q0Zt3jcwqfOgbDuwQ X-Google-Smtp-Source: ADFU+vvoy7XH/PqCRJ9o2gobWeHrmL6McT++EUjXuXCzyJcMTYUfJKh63qC361kC12IA2l24O7A4DA== X-Received: by 2002:ae9:e003:: with SMTP id m3mr17427447qkk.250.1583788487128; Mon, 09 Mar 2020 14:14:47 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.31.1]) by smtp.gmail.com with ESMTPSA id r15sm5137380qtr.40.2020.03.09.14.14.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 14:14:46 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 1E2CC3008D9; Mon, 9 Mar 2020 18:14:44 -0300 (-03) Date: Mon, 9 Mar 2020 18:14:44 -0300 From: Alvaro Herrera To: Pg Hackers Subject: Re: time for catalog/pg_cast.c? Message-ID: <20200309211444.GA24535@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200309210003.GA19992@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Mar-09, Alvaro Herrera wrote: > I extracted from the latest multirange patch a bit that creates a new > routine CastCreate() in src/backend/catalog/pg_cast.c. It contains the > catalog-accessing bits to create a new cast. It seems harmless, so I > thought I'd apply it to get rid of a couple of hunks in the large patch. I forgot to "git add" this comment addition before sending: /* * ---------------------------------------------------------------- * CastCreate * * Forms and inserts catalog tuples for a new cast being created. * Caller must have already checked privileges, and done consistency * checks on the given datatypes and cast function (if applicable). * * 'behavior' indicates the dependency that the new cast will have on * its input and output types and the cast function. * ---------------------------------------------------------------- */ ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext, char castmethod, DependencyType behavior) I think the only API consideration here is for 'castcontext', which we pass here as the pg_type.h symbol, but could alternatively be passed as CoercionContext enum values (from primnodes.h). I think the pg_cast.h char is okay, but maybe somebody has a different opinion. We could also add some trivial asserts (like if procoid is not invalid, then method is function, etc.), but it doesn't seem worth fussing too much over. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services