Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCNpn-0000ia-M9 for pgsql-general@arkaria.postgresql.org; Tue, 25 Jan 2022 15:34:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nCNpm-0006Xq-Io for pgsql-general@arkaria.postgresql.org; Tue, 25 Jan 2022 15:34:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCNp0-0000Bo-TQ for pgsql-general@lists.postgresql.org; Tue, 25 Jan 2022 15:33:26 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nCNoy-000279-Of for pgsql-general@postgresql.org; Tue, 25 Jan 2022 15:33:25 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d7so19642725plr.12 for ; Tue, 25 Jan 2022 07:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J5x0ygA/SpMPoPBLXr56st4bxFMvuCfRq5yZufmzrJw=; b=HPpXhYEA1GqnfiCAtAVSTYpOKlX/2Hfq+Bkm+p7d+ko2oBy0K4YMMjaTx0foRk4Ejb hjzEbbt7sHUYHmJAQbJhTA++xMv5l2ma2wRQ1KvRoMie4rBFDYF7/gSeh5s7AdGMhOne yIBuVKf+5AP/q+eSKBB7EPoKRwFHpNTX6GiSDZ5EwszjvRMgVzFXXiybv/Iy3Lcd+477 mOnArpfnALHGHBgFmxCjlOwTohmYdEXCdT4KracoWWhq/1/mbdBIlaz6VMT9iiTl1xVf 9LxL/X25XIrMmRpf/J/RkAeH8cXB3kApm+OBESaLBL1PQgA6loxxV3ukUaMbSXzsttkr Fo9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J5x0ygA/SpMPoPBLXr56st4bxFMvuCfRq5yZufmzrJw=; b=MR6U9tYYrL7MapyA3P+pa38QQ6DBXCejslNuiqgwLQEBGfeH3BLZThk0LuJaHTq+l2 /QTRoVipa9Ipp6yOQ9L0M3YAWeAgtmT/XtCID5amgb2r3qnBwQBkWkYxd/n/nCEHfBdK nNTOF+k/1WPVKmxHh6C1ah61JS1MUbr7xX5yH6RYGPlBzM9sEwwkOWQTIYK3l0oBBsDw Vd7D1KzLJUwJ+RAsflup3F+8wBIGuzlgJIT5Ssc4Ril/cQgIVNoEGVxK1+6VWweIAFqB PFsT3tP4YPkJAOEo+9qQn14AYF6JAk5uii5AfLGWmkJP4ua60hB7KuFGNmPBpOJ39SRK Rkcw== X-Gm-Message-State: AOAM531pAF5/H0XQGMSPvtgDd/uDNW9TP5ocbEHEYvYqs81/UE9JWmTu E7aOYLcmkwUUCFmdeuR0+YdJvQfEBvn4MA== X-Google-Smtp-Source: ABdhPJyidvB7Oj06Kf42XDXBpRXqTIvUi1athEdY9Z6Ide1OaJHbRvIhHS7ogKjram6C/Rh+kmq5Mg== X-Received: by 2002:a17:90b:2281:: with SMTP id kx1mr4050414pjb.37.1643124803822; Tue, 25 Jan 2022 07:33:23 -0800 (PST) Received: from jrouhaud (1-171-59-176.dynamic-ip.hinet.net. [1.171.59.176]) by smtp.gmail.com with ESMTPSA id mq15sm887679pjb.8.2022.01.25.07.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 07:33:23 -0800 (PST) Date: Tue, 25 Jan 2022 23:33:19 +0800 From: Julien Rouhaud To: "huangning290@yahoo.com" Cc: "pgsql-general@postgresql.org" Subject: Re: GIN index Message-ID: <20220125153319.bw3hsdm5epfkm2j6@jrouhaud> References: <147894193.1340405.1643078534794.ref@mail.yahoo.com> <147894193.1340405.1643078534794@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <147894193.1340405.1643078534794@mail.yahoo.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Jan 25, 2022 at 02:42:14AM +0000, huangning290@yahoo.com wrote: > Hi:I created a new variable-length data type, and now I want to create a GIN > index for it. According to the rules of GIN index, I created three functions: > extractValue, extractQuery, and compare. I made sure that the return value of > the first two functions is the address of the array, but when using the index > query, the GIN tuple data obtained by calling PG_GETARG_DATUM in the compare > function is incorrect, and it is misplaced! In memory the size of the data > header becomes something else, and the position of the first byte is not the > header, it becomes the fourth byte. So there is a high probability that the > function called is wrong or my return value is wrong when creating the index > or the error is somewhere else? It's hard to have an opinion without seeing any code extract. Have you checked contrib module for examples of other GIN opclasses, like pg_trgrm, or hstore for varlena datatype with GIN support? Note also that pgsql-hackers is probably a better mailing list for this kind of questions.