Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u1hSZ-006e7j-7j for pgsql-docs@arkaria.postgresql.org; Mon, 07 Apr 2025 08:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u1hSW-00DVji-2h for pgsql-docs@arkaria.postgresql.org; Mon, 07 Apr 2025 08:03:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u1hSV-00DVja-PQ for pgsql-docs@lists.postgresql.org; Mon, 07 Apr 2025 08:03:56 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u1hSQ-003sw4-0R for pgsql-docs@lists.postgresql.org; Mon, 07 Apr 2025 08:03:55 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-ac2aeada833so800589766b.0 for ; Mon, 07 Apr 2025 01:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1744013028; x=1744617828; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=4BT6X/6y+au+UPQTN3qmdSWjKK+09+koa5Yp5UFpWDw=; b=pT17/lV+O/gsK/ZHkJG3eMeogwC+Z0+tQfeHO3NGZciypgJCuWSw29lDKeFp85FVh5 o4ld+d1C/WCTCcqIs3EyFfo46EgEOKaWspjhCpQCUkFUl3edr5pSj/UbTcewn3kBSLY1 BkBIggbsg+GG3G2HvSqDv1F1Og/8sOo31qDgdVsb1lNHgUR8xrIkg1e5yPJT4GcWKwf0 3XYAyXxkCwC6VCj5vQsQbXWwMNQlJC0Rvdu1Icut9pD2FIetTHwa0uZhwY2UOckBiDTS bxdZUQ/7ZxL4Bb0WxbD/ewwMPQqrXrVtY57e8UON4NRLBMYn+hY9uCgrtIiHvIPjttxQ +Iww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744013028; x=1744617828; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4BT6X/6y+au+UPQTN3qmdSWjKK+09+koa5Yp5UFpWDw=; b=txopLNUBC/GmjpC9NVVJwUK3UCqaPwnGPva/+wAC43Iwmjnf2ygHup+lIsOJWGnJaH MSyn2kJXRD3cK2ZvXpTCTqIReVZfYY6c1i7Xx7aETMCzTTnTw+NbSKiZLoA76VBPH/U5 bfd1wd/b1g9smiXAzkR8X6GyoiS5GIXv5Oi6jODYRhuF3iKlqC/RvEqTMvm8UZ9+fET4 HzHlLe532yGbl7kkNPGpeMTJwhfWH7UbvFCguMwpu1v+txYs1UUmfyJavqHW9NJUBaBd BpEHh/nMbzy1KTSY7wVcHFrihHI5kzm6a1ocuWQn/CPJOvUG8kGFP+F5hgO5C54adD0Q CvPQ== X-Forwarded-Encrypted: i=1; AJvYcCUfzZ3ZsjYIbm/B+A8y8UG1ce9OTymwZ1bmqB/8ZnFgBED8L+BDa4ZNE/WuLQoviifFl+dSjI5eja7v@lists.postgresql.org X-Gm-Message-State: AOJu0YwMJdgxzGFki/WMSHn2tAkA19qXdRZ9Ym8ioSxP3xvc6/BXfA4F ZwSE9cePUab75BDe+QH71UY3KD+ZU+Zd28zPPJr7Y/VIAGJfZDBfetn8aJTVXUSTvP6I92R8gny s X-Gm-Gg: ASbGnctLNToedNNOf30VDxSANJA7zYYf8gKt7MlRMd67IxlGnEfDiT5L+xLqf1Dc9wj pdQjzJKj3QsLueWz/VaROuIX5/6xYLpdveQ+sWriI2qANbI6AO/AWgDX5BJaa6tJQKm5pQBEaDc oS1cBnaDrmYRvRLXnmEdgGhH6hCCzWX2eeSf7sYt/BDRi4P95atK8+M5PB2RfQeejrgNpRqzrDM hOIGAUcDL5pgIc0Z7UHd6r4JPKeoZFE2x8OHaN/kp0Jwh4AwfFDsAo1Eusn+EKyW29kuIQ2txxb QsHTIx/csVAXHELY5Ye53UGbKKeJFqK2wff1BU82TTdxz+swZellw2EhCZhfjnIKwg== X-Google-Smtp-Source: AGHT+IHAtO9xb+u6HrBhUUlkTOV+fIOD2UZ3pflKfzYiTyN+Uh//7Iv/qdUUiSled7O+Ri8uLU0q6Q== X-Received: by 2002:a17:907:86a3:b0:ac3:8537:9042 with SMTP id a640c23a62f3a-ac7d3175f9bmr1161408366b.30.1744013028422; Mon, 07 Apr 2025 01:03:48 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:9a63:6e75:d921:166e:9c61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac7c01c2e6dsm712314466b.174.2025.04.07.01.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 01:03:48 -0700 (PDT) Message-ID: <488788bd2526cec7eb175741c010cab2fa24fed4.camel@cybertec.at> Subject: Re: Suggestion for docs, section "4.2.3 Subscripts": bounds and base From: Laurenz Albe To: s@xss.de, pgsql-docs@lists.postgresql.org Date: Mon, 07 Apr 2025 10:03:47 +0200 In-Reply-To: <174370454407.3115968.6902015899222362259@wrigleys.postgresql.org> References: <174370454407.3115968.6902015899222362259@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-04-03 at 18:22 +0000, PG Doc comments form wrote: > Page: https://www.postgresql.org/docs/17/sql-expressions.html > Description: >=20 > I skimmed over section 4.2 while waiting for a meeting to start and found= no > mention of the following two questions that immediately pop up in my mind > when subscripts are mentionned: >=20 > Are subscripts 0-based or 1-based? This question is answered in the documentation of the array data types: https://www.postgresql.org/docs/current/arrays.html The array subscript numbers are written within square brackets. By defaul= t PostgreSQL uses a one-based numbering convention for arrays, that is, an array of n elements starts with array[1] and ends with array[n]. > Are slice boundaries inclusive or exclusive? That becomes clear on the same page: We can also access arbitrary rectangular slices of an array, or subarrays= . An array slice is denoted by writing lower-bound:upper-bound for one or more array dimensions. For example, this query retrieves the first item on Bill's schedule for the first two days of the week: SELECT schedule[1:2][1:1] FROM sal_emp WHERE name =3D 'Bill'; schedule ------------------------ {{meeting},{training}} (1 row) Admittedly, there is no exact definition, but the example makes clear that the boundaries are inclusive. I don't think that we need to repeat that information. Yours, Laurenz Albe