Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chLxh-0000ct-9b for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Feb 2017 19:55:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1chLxg-0002xW-PS for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Feb 2017 19:55:28 +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.84_2) (envelope-from ) id 1chLxf-0002wc-CD for pgsql-hackers@postgresql.org; Fri, 24 Feb 2017 19:55:27 +0000 Received: from mail-qt0-x234.google.com ([2607:f8b0:400d:c0d::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1chLxc-0003oM-4V for pgsql-hackers@postgresql.org; Fri, 24 Feb 2017 19:55:26 +0000 Received: by mail-qt0-x234.google.com with SMTP id r45so25236988qte.3 for ; Fri, 24 Feb 2017 11:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=CvCjKCuabmnrmppoTKnrjoS8EQND6GR/45cOiiExNsY=; b=bMbSjErO2CzPBGnUVB8E7wQ+DAwUkYBc+gurIVpf/vne8IYMJG1MfhwbzV7djgoiMT xYhBOz7KlGvitq8aeOO5Zv5/L+I6pugkCv+ZS0G90QKGN180WnUlRgCcfxbpOATMZZdY ubLizGQG0mccG9iWc8KJHus9QOVBG8xfZmpQWcr7HhfhlET1xibI2QC5PR20iLGUqSCG 9JcA3CCnWpyG1YIZqcOyPT6wLfew9P20xSRAKbDs+kuMDEXF6X9AAEFH2GHjDmZiWBur 9n12oIqwRm93R+fp9Un4p8SvgyTb/ZpPkjG88vP6BQXjnrkX6CI+kfReYocmaQvHvOl5 u24Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=CvCjKCuabmnrmppoTKnrjoS8EQND6GR/45cOiiExNsY=; b=gG3xCL3qaWBsNvK6FohNN3zOWmIzXtOoXxQ43FEM01ClrXpFJ7cBXModpWQBNl4yNK cb/DWjmEIjNhEtPjF8OfOyp7LKlKbO5I0a/uXstctwdRxySLqL6C8KbIuk8ERMPsSqW7 Fz2guuJyE46aaf3Lj4s0mbLfK0cgI+ANfKcugYDdn+eyl5BNVsPxJrDAp8mYHDuOWbx7 Tk/tDHO980FLKuWMEgvJDr4S8NuBwr+rgPokOb5ICMJWOZJ+IzDH2JSHR5x0quoObb1X bsxz6E4v8bnkENbxDoHA2g1h16LRW28bEnmYgjoWQHLiq3ZF0m2ERhNxjfHLeyoYKHxn lxZQ== X-Gm-Message-State: AMke39lGUkxeGYo/fwUHSLnMRXzlOk+MKcrpBq2xPKKRiRDvYdX6BeyojiaWIqV0Vh3+dccRGyMNoxVtC/N2fQ1VXdBwdUjE22F9+6M8cj0pnkRI2um9miDuMqDCkClGV9IF5BK7Z9Y58lC3Q3PEvdhcD8qXYZPqnaOn/1LdLZjNbPQlMAkS05da9tlp8xgn3tXLUSZxNDIdF9M= X-Received: by 10.200.55.55 with SMTP id o52mr4399013qtb.279.1487966122407; Fri, 24 Feb 2017 11:55:22 -0800 (PST) Received: from [192.168.10.146] ([98.122.164.227]) by smtp.gmail.com with ESMTPSA id h33sm5420534qtc.42.2017.02.24.11.55.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 11:55:22 -0800 (PST) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: btree_gin and btree_gist for enums To: Tom Lane References: <56EA8A71.8060107@dunslane.net> <56EACB8C.1040406@dunslane.net> <03f7d748-0f89-e8e1-094d-f04e1026b93d@dunslane.net> <27220.1478360811@sss.pgh.pa.us> <31412.1478366009@sss.pgh.pa.us> <60fb708c-8b3c-1337-934e-c1bfe2afc539@dunslane.net> <8258.1487886101@sss.pgh.pa.us> <4376a7bf-ab8c-e640-9021-94b148f9d733@2ndQuadrant.com> <6704.1487952174@sss.pgh.pa.us> Cc: PostgreSQL-development Message-ID: <930cb563-6dc6-c4af-3be9-31f06c60361e@2ndQuadrant.com> Date: Fri, 24 Feb 2017 14:55:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <6704.1487952174@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 02/24/2017 11:02 AM, Tom Lane wrote: > Andrew Dunstan writes: >> On 02/23/2017 04:41 PM, Tom Lane wrote: >>> The reason this is kind of scary is that it's just blithely assuming >>> that the function won't look at the *other* fields of the FmgrInfo. >>> If it did, it would likely get very confused, since those fields >>> would be describing the GIN support function, not the function we're >>> calling. >>> >>> We could alternatively have this trampoline function set up a fresh, local >>> FmgrInfo struct that it zeroes except for copying fn_extra and fn_mcxt >>> from the caller's struct, and then it copies fn_extra back again on the >>> way out. That's a few more cycles but it would be safer, I think; if the >>> function tried to look at the other fields such as fn_oid it would see >>> obviously bogus data. >> Do we want one or both of these? I'm prepared to code up a patch to >> fmgr.[ch] to provide them. > On reflection I'm not sure that the double-copy approach is all that much > safer than just passing down the caller's flinfo pointer. Most of the > time it would be better, but suppose that the callee updates fn_extra > and then throws elog(ERROR) --- the outcome would be different, probably > creating a leak in fn_mcxt. Maybe this would still be okay, because > perhaps that FmgrInfo is never used again, but I don't think we can assume > that for the case at hand. > > At this point I'd be inclined to just document that the called function > should only use fn_extra/fn_mcxt. fair enough. Will do it that way. > >> I don't know what to call it either. In my test I used >> CallerContextFunctionCall2 - not sure if that's quite right, but should >> be close. > CallerInfo? CallerFInfo? Or we could spell out CallerFmgrInfo but > that seems a bit verbose. > > I'll go with CallerFInfoFunctionCall2 etc. In the btree_gist system the calls to the routines like enum_cmp are buried about three levels deep. I'm thinking I'll just pass the flinfo down the stack and just call these routines at the bottom level. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers