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 1noLW5-0006f3-2b for pgsql-committers@arkaria.postgresql.org; Tue, 10 May 2022 08:46:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1noLW3-0004bA-P3 for pgsql-committers@arkaria.postgresql.org; Tue, 10 May 2022 08:46:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noLW3-0004b1-En for pgsql-committers@lists.postgresql.org; Tue, 10 May 2022 08:46:47 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1noLW1-0005lq-RD for pgsql-committers@lists.postgresql.org; Tue, 10 May 2022 08:46:47 +0000 Received: by mail-ot1-x331.google.com with SMTP id y14-20020a9d460e000000b00605ee347da1so11758042ote.8 for ; Tue, 10 May 2022 01:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZdApXGRxgQUOWhilEYQUIXdWWvYnEldLMhpqv2t4vbQ=; b=E9eWjMLGBbKANhX+LzdqnaejZb3GljS4kyupgnmlPe2NOmD84aO8H+lUUhTm/gWdlT MKxuRGAx6uua5aALiZrg78t16stTBzbIiDj/6HJhYhHEJQR768HX8y1gbWD2K/fs1gyL X5a+MgGLNByr+BzV9lat/4QjlMaVu8Zt8ZftZTkP4wVBrsb8MpihJrFy9z630BpnfH8p X4xCG+KLAaF1l5/9V24Sgl2rX9K2A+4to7wl5AvAemlCDEudtmtCBaX43cYVGhP4HDYF gvLK/7BkGR8bP0/asxoh4u0RzTAccA3saacGP1MrqFzWrtmAOVDl5X93eK2uzFmY2EfK JBGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZdApXGRxgQUOWhilEYQUIXdWWvYnEldLMhpqv2t4vbQ=; b=e0FZvuOfIybhPGxwDh9NDpvCdOYPwzU7b2f93MfoPKx0mweL8EDAKUDixf28nBVQCC czZJ+VsgQAiXFk01Yaq0WpSFd9xrzNZGbFmaT/Gk6xBNiEIieP6HcV0U6DsuH7y1Sfpb 1r1lLwNmy3ar5GcJGN7BeBJvI2MsT/XMEtBtpP60NCywVUKNRD31Cl9eml9lPJqNdjsP WbMHnYkk1Bu34t2P0PRdCkuC1pcu2ZQL+KwvDlxkSD2p0bpPznnGP8Z9TbAwxqtediX+ zM2v9z7Zn/obkNVZMvFvbrL+ZQItvJleo6GUsqB17Vrh8JiwtYHsZAq46sqZVUnGZ+in YLhQ== X-Gm-Message-State: AOAM531+rIXjJKLU5p2XUl/AdBWuviTC1ScecYII7T6a9/TjGx29wgR0 5x895kw9IVTA0MxmNhVF57NJK6iJVrxkhlRGABU= X-Google-Smtp-Source: ABdhPJxIn3OWM8t0DHilQoJwN/nSauD4sZw6IgozyDFhQEdGXfaZOTlZNLpM0Ui0wes2nz7mtZ5j4kwAgBK7v6Sm3b0= X-Received: by 2002:a9d:5184:0:b0:605:ea2e:72cb with SMTP id y4-20020a9d5184000000b00605ea2e72cbmr7696950otg.234.1652172403962; Tue, 10 May 2022 01:46:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Tue, 10 May 2022 20:46:29 +1200 Message-ID: Subject: Re: pgsql: Specialize tuplesort routines for different kinds of abbreviated To: John Naylor Cc: pgsql-committers@lists.postgresql.org, Thomas Munro Content-Type: multipart/mixed; boundary="0000000000003f21de05dea45d61" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003f21de05dea45d61 Content-Type: text/plain; charset="UTF-8" On Sat, 2 Apr 2022 at 21:30, John Naylor wrote: > src/backend/utils/sort/tuplesort.c | 160 ++++++++++++++++++++++++++++++++- I was just looking over this change and wondered a few things: 1. Shouldn't ssup_datum_signed_cmp and ssup_datum_int32_cmp be using DatumGetInt32 and DatumGetInt64? 2. I also feel that it's relevant to comment about 32-bit safety for usages of these functions. I'm trying to work out what the point of ssup_datum_signed_cmp is when SIZEOF_DATUM == 4. As far as I see, we just never use it. However, looking at btint8sortsupport(), we seem to set the comparator based on USE_FLOAT8_BYVAL rather than SIZEOF_DATUM. It's true in master that USE_FLOAT8_BYVAL will be 1 if SIZEOF_VOIDP >= 8, per: #if SIZEOF_VOID_P >= 8 #define USE_FLOAT8_BYVAL 1 #endif #define SIZEOF_DATUM SIZEOF_VOID_P This is hypothetical, but if for some reason SIZEOF_VOIDP was larger than 8, say 16, then the above would define USE_FLOAT8_BYVAL resulting timestamp and bigint using the new comparators. However, the code you've added to ssup_datum_signed_cmp checks for SIZEOF_DATUM == 8. It would assume 32-bit accidentally. That would cause issues.