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 1nKadC-0008If-9O for pgsql-docs@arkaria.postgresql.org; Thu, 17 Feb 2022 06:51:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKadB-00039C-4G for pgsql-docs@arkaria.postgresql.org; Thu, 17 Feb 2022 06:51:09 +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 1nKadA-00038U-R6 for pgsql-docs@lists.postgresql.org; Thu, 17 Feb 2022 06:51:08 +0000 Received: from mail-ua1-x934.google.com ([2607:f8b0:4864:20::934]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKad5-0006v7-NL for pgsql-docs@lists.postgresql.org; Thu, 17 Feb 2022 06:51:07 +0000 Received: by mail-ua1-x934.google.com with SMTP id w37so262201uad.10 for ; Wed, 16 Feb 2022 22:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AxngvHQCDP+NpIEKF3Vq3zlrBi0vA7PhCNXltBY6d70=; b=mpyUxiDKVvlPLEQazNKWqnVLsIUVoi9R47fil9GgRtFflr6y8F+iFTLTaegJ0HoxRn kGHiNdCZun/i0jHlPkdtFZc4z+QlT3/QIi9iVMdCo3saWjjxvZc1lWk8rjCUazqdDKER ZR9tCZd1wdv7hjTTfOETt3jomYaLHCo9Cerh3fJ0SwJ/y3S/TiQ3Fz6ZJmyhPNNwvZCP GNipcJ2CqDQQZ2BLrzi2CLVUEH2d8t44TbdcNdkB4CbOVZB9fuAqisyoN5ChWuTYLv6L MgIF8HTArTxYDiBAQUFPK/rFNutHr6u/49BRAwSbrblQRUlRls77r6jzDM+Kr5gzaFLi IjwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AxngvHQCDP+NpIEKF3Vq3zlrBi0vA7PhCNXltBY6d70=; b=Rf6x/e4cmECbNm+lHF7acMgX80E+/W3+C9jR8jgep9HDZLHwCqY46lfhEn4GCyJLRb 90F8hHD+nB0qV4UH+vzKvnXD1GKULtMMKWfo9evGkzLqa0FLKpVRMPqT9gBIdwcMSNag /3xNvwMja28nMSjHSsz/lO9jSNUurkKhE/utTsqFperCWc1VIPy2Fn2C0ed7OSVgkP65 +MjXSMZbDjM5LdsMmorDB5d9CkjpqHP4AQ42i0+a7iCLErPeOK/3G2I7R1s3o1iOsv8Q wt543l0W6ZfpFV40qXE6G54++QLakAKbfun8MIBuexlhJ/k5vx3QueXkX91Kyy8yR3K1 sYRg== X-Gm-Message-State: AOAM5328TGWpBuW9b7Ly9RjDhCIisJABt1zGkKo7dVtTEHxaYBVVURET etuiZYsM59PfVSIFaL2HUkhQ7LkN09a9xeTkYqo= X-Google-Smtp-Source: ABdhPJwwQzr7iVkz+yISouQyBVkHYBDW55hqY30MhCQgK0V+9v38BgCD33Ob7Dhn6WOAJGYuuOV7pEzDzdhjvS5SA6g= X-Received: by 2002:ab0:76d8:0:b0:33c:9bea:fa2c with SMTP id w24-20020ab076d8000000b0033c9beafa2cmr558414uaq.44.1645080662614; Wed, 16 Feb 2022 22:51:02 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a59:a921:0:b0:27f:dd4a:c8d7 with HTTP; Wed, 16 Feb 2022 22:51:02 -0800 (PST) In-Reply-To: References: From: "David G. Johnston" Date: Wed, 16 Feb 2022 23:51:02 -0700 Message-ID: Subject: Re: range data type size not mention in docs. To: Jian He Cc: "pgsql-docs@lists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000085a63405d83130da" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000085a63405d83130da Content-Type: text/plain; charset="UTF-8" On Wednesday, February 16, 2022, Jian He wrote: > > range type seem not mention their size in the docs. > multi range size is variable. > But range size seems fixed. > why it's 17 byte? > > select pg_column_size('[10,20)' ::int4range ); --17 byte > select pg_column_size('[-2147483648,2147483647)' ::int4range ); --17 byte. > > https://github.com/postgres/postgres/blob/4429f6a9e3e12bb4af6e3677fbc78cd80f160252/src/backend/utils/adt/rangetypes.c#L183 * Binary representation: The first byte is the flags, then 4 bytes are the * range type Oid, then the lower bound (if present) then the upper bound (if * present). Each bound is represented by a 4-byte length header and the binary * representation of that bound (as returned by a call to the send function for * the subtype). David J. --00000000000085a63405d83130da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wednesday, February 16, 2022, Jian He <hejian.mark@gmail.com> wrote:

range type seem not mention the= ir size in the docs.
multi range size is variable.
But range size seems fixed.
why it's 17 byte?
select  pg_column_size('[10,20)=
' ::int4range ); <=
span style=3D"color:rgb(105,152,86)">--17 byte
select p= g_column_size('[-21474836= 48,2147483647)' ::in= t4range ); --17 byte.
https://github.com/=
postgres/postgres/blob/4429f6a9e3e12bb4af6e3677fbc78cd80f160252/src/backend=
/utils/adt/rangetypes.c#L183=C2=A0
* Binary representation: The first byte is the flags, then 4 bytes are=
 the
 * range type Oid, then the lower bound (if present) then the upper bound (=
if
 * present). Each bound is represented by a 4-byte length header and the bi=
nary
 * representation of that bound (as returned by a call to the send function=
 for
 * the subtype).
David J.

--00000000000085a63405d83130da--