Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYL0R-00014b-8g for pgsql-students@arkaria.postgresql.org; Mon, 21 Oct 2013 19:19:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VYL0Q-0000Lm-On for pgsql-students@arkaria.postgresql.org; Mon, 21 Oct 2013 19:19:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYL0P-0000Ld-Rv; Mon, 21 Oct 2013 19:19:09 +0000 Received: from mail-qc0-x22d.google.com ([2607:f8b0:400d:c01::22d]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYL0H-0005Nv-JN; Mon, 21 Oct 2013 19:19:09 +0000 Received: by mail-qc0-f173.google.com with SMTP id l13so4792345qcy.18 for ; Mon, 21 Oct 2013 12:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=pyC/e5aKclMizYVHcaNhIZAa7TGE+YQonHWkfnuXH9M=; b=TSqGjetYwr+ZGtD5LkNLwUrwmrFYWVHPIS069DKH+103GLlxqpd5Rt4akdbb3zDW2a 7Ck8j7e507UoWAZ2AJ30G8AuZRQkr6Lasg9IgbfPJivv1E/Pe/X6dPIzNYetnln9r8y4 nogPfmvalev3XFe+DZAd0O7XHEA8Xj7YFQ7oNQHD5nwPh9I3pVVlaaZPdIcwM9SoT1Xx knqKz4jpxIhVOSXA2tojI+vAV5TbrXU6ReQjELintQunUECtIb9l3Z9/EMbxexZM5kq3 qlIkUEWcf4GZi4UEXU9I9WDynHtXN8m6qv1PPlzYcLVIp0iTKfX9BvxOsOiowWY+9cx2 Inog== X-Received: by 10.229.101.136 with SMTP id c8mr24532096qco.17.1382383140386; Mon, 21 Oct 2013 12:19:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.189.135 with HTTP; Mon, 21 Oct 2013 12:18:40 -0700 (PDT) In-Reply-To: <52657B1C.7050906@vmware.com> References: <23364502-F542-4553-A658-4D3A2B6FCFA9@gmail.com> <5236A9BC.3030000@vmware.com> <5258038C.9070409@vmware.com> <52657B1C.7050906@vmware.com> From: Alexander Korotkov Date: Mon, 21 Oct 2013 23:18:40 +0400 Message-ID: Subject: Re: [HACKERS] Cube extension point support // GSoC'13 To: Heikki Linnakangas Cc: Stas Kelvich , Robert Haas , pgsql-hackers , pgsql-students@postgresql.org Content-Type: multipart/alternative; boundary=001a11c3face06bf7104e9452821 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-students Precedence: bulk Sender: pgsql-students-owner@postgresql.org --001a11c3face06bf7104e9452821 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Oct 21, 2013 at 11:06 PM, Heikki Linnakangas < hlinnakangas@vmware.com> wrote: > On 11.10.2013 17:39, Alexander Korotkov wrote: > >> On Fri, Oct 11, 2013 at 5:56 PM, Heikki Linnakangas> vmware.com >> >>> wrote: >>> >> >> 2. I didn't understand this change: >>> >>> @@ -422,24 +439,14 @@ g_cube_union(PG_FUNCTION_ARGS) >>> >>>> Datum >>>> g_cube_compress(PG_FUNCTION_****ARGS) >>>> { >>>> - PG_RETURN_DATUM(PG_GETARG_****DATUM(0)); >>>> >>>> + GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); >>>> + PG_RETURN_POINTER(entry); >>>> } >>>> >>>> Datum >>>> g_cube_decompress(PG_FUNCTION_****ARGS) >>>> >>>> { >>>> GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); >>>> - NDBOX *key = DatumGetNDBOX(PG_DETOAST_**** >>>> DATUM(entry->key)); >>>> >>>> - >>>> - if (key != DatumGetNDBOX(entry->key)) >>>> - { >>>> - GISTENTRY *retval = (GISTENTRY *) >>>> palloc(sizeof(GISTENTRY)); >>>> - >>>> - gistentryinit(*retval, PointerGetDatum(key), >>>> - entry->rel, entry->page, >>>> - entry->offset, FALSE); >>>> - PG_RETURN_POINTER(retval); >>>> - } >>>> PG_RETURN_POINTER(entry); >>>> } >>>> >>>> >>>> What did the removed code do, and why isn't it needed anymore? >>> >> >> I don't understand this place even more generally. What decompress >> function >> do is to detoast key and return new gist entry with it if needed. But can >> GiST key ever be toasted? My experiments show that answer is no, it can't. >> When too long key is passed then GiST falls during inserting key into >> page. >> And I didn't find any code doing GiST key toast in git. >> > > I guess it can't happen. Or is it possible that a toasted value that came > from disk will be passed to these functions, without detoasting them > somewhere along the way? Not sure. > I will ask Teodor about it. When situation will be completely clear we should cleanup confusing comments. Also, too long GiST key shouldn't cause GiST to fall in its internals. We should add check somewhere before. In any case, I've committed this patch now. I left out the changes to > compress and decompress functions, as that's unrelated to the patch at > hand. I ran the regression test on a Windows VM, and updated the expected > output file that the Windows build used. That leaves two alternative > expected output files unmodified - the buildfarm will tell us whether > they're still needed. > > Thanks and congrats on your first committed patch, Stas! :-) Stas, congratulations from me too! Now, it's time to rebase another patches against head. :) ------ With best regards, Alexander Korotkov. --001a11c3face06bf7104e9452821 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Oct 21, 2013 at 11:06 PM, Heikki Linnakangas <hlinnakangas@vmware.com> wrote:
On 11.10.2013 17:39, Alexander Korotkov = wrote:
On Fri, Oct 11, 2013 at 5:56 PM, Heikki Linnakangas<hlinnakangas@vmware.com=
wrote:

2. I didn't understand this change:

=A0 @@ -422,24 +439,14 @@ g_cube_union(PG_FUNCTION_ARGS)
=A0 Datum
=A0 g_cube_compress(PG_FUNCTION_**ARGS)
=A0 {
- =A0 =A0 =A0 PG_RETURN_DATUM(PG_GETARG_**DATUM(0));

+ =A0 =A0 =A0 GISTENTRY =A0*entry =3D (GISTENTRY *) PG_GETARG_POINTER(0); + =A0 =A0 =A0 PG_RETURN_POINTER(entry);
=A0 }

=A0 Datum
=A0 g_cube_decompress(PG_FUNCTION_**ARGS)

=A0 {
=A0 =A0 =A0 =A0 =A0GISTENTRY =A0*entry =3D (GISTENTRY *) PG_GETARG_POINTER(= 0);
- =A0 =A0 =A0 NDBOX =A0 =A0 =A0*key =3D DatumGetNDBOX(PG_DETOAST_**D= ATUM(entry->key));

-
- =A0 =A0 =A0 if (key !=3D DatumGetNDBOX(entry->key))
- =A0 =A0 =A0 {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 GISTENTRY =A0*retval =3D (GISTENTRY *)
palloc(sizeof(GISTENTRY));
-
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 gistentryinit(*retval, PointerGetDatum(key),<= br> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 entry->rel, entry->page,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 entry->offset, FALSE);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 PG_RETURN_POINTER(retval);
- =A0 =A0 =A0 }
=A0 =A0 =A0 =A0 =A0PG_RETURN_POINTER(entry);
=A0 }


What did the removed code do, and why isn't it needed anymore?

I don't understand this place even more generally. What decompress func= tion
do is to detoast key and return new gist entry with it if needed. But can GiST key ever be toasted? My experiments show that answer is no, it can'= ;t.
When too long key is passed then GiST falls during inserting key into page.=
And I didn't find any code doing GiST key toast in git.

I guess it can't happen. Or is it possible that a toasted value that ca= me from disk will be passed to these functions, without detoasting them som= ewhere along the way? Not sure.
=A0
I will a= sk Teodor about it. When situation will be completely clear we should clean= up confusing comments.
Also, too long GiST key shouldn't cause GiST to fall in its intern= als. We should add check somewhere before.

In any case, I've committed this patch now. I left out the changes to c= ompress and decompress functions, as that's unrelated to the patch at h= and. I ran the regression test on a Windows VM, and updated the expected ou= tput file that the Windows build used. That leaves two alternative expected= output files unmodified - the buildfarm will tell us whether they're s= till needed.

Thanks and congrats on your first committed patch, Stas! :-)

Stas, congratulations from me too! Now, it's time to = rebase another patches against head. :)

------
With best regards,
Alexander Korotkov.
=A0
--001a11c3face06bf7104e9452821--