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 1oWDXr-0006sc-1x for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Sep 2022 09:09:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDXp-0007do-SC for pgsql-bugs@arkaria.postgresql.org; Thu, 08 Sep 2022 09:09:57 +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 1oWDDf-0001ic-D4 for pgsql-bugs@lists.postgresql.org; Thu, 08 Sep 2022 08:49:07 +0000 Received: from mail-sy4aus01on2139.outbound.protection.outlook.com ([40.107.107.139] helo=AUS01-SY4-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWDDc-0004Iw-Ck for pgsql-bugs@lists.postgresql.org; Thu, 08 Sep 2022 08:49:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Po/SRBtNl3Yj01jrzCykVtZ0d/CZvBDrcFqo7YuXg5+Lmt+bQp4i5Abs7BHigYspO5Lq6ap5LNooQb8oZUpIPID6+mWhslRvXzcX0s8eazCmc1+zh3zu//cg7HshTcMFqxuN/AASqcusbubx/u3Jy7SQrcTVA4Nk43WDPVcsD4f2xL9CUF/EWSc+3CW+YvLL6x0l9uAj/0RoKnSCf1zPdtuPyJB+RquWVcO3ocjCR+99d3ArbqwEGS136mrgRO4IyyHJfY0cx7Avcd4DDioV6z1ZSIx6hDK8WiSeg/RSN1XKU48leBIdZnAQamjyDPNxrjrj5usd10ltzJR96SeHWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ygp8QnbBDGj9snfuHm7oHxIOWfZu8w7RqA+JJsjN+ks=; b=THj0dQdI/LptCdeMyGknMjr+diByfJ/vt+Xlf/+cyd9jfZjUR4DloN5WJ2R5yB1aAnBmecop9hK5axQSeZCZsKta9ZgUfOLrdq4JIWVgrdEgx0jIvcXvjjjxBUbV2Ua5nw/JLwjtpvYhxm67PgL5GhcypJlnNkT8ROcA+wGxk1gbRMwPOKUcKS4Aa2Za2BzEa9/gtnBlu9IBhFSOiOvuq6gmiq+/Qq0da24vPVS24q+F0B/PoAufU/XoCvqiGlSDEAuWPZfBvO77mDc25G25muYpMxqcr1iwr0zwuDOBfsWgZSSTLsgy2RIyonZZv001BE4sPBBEXGo587yfcPr4QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cleanstormwater.com.au; dmarc=pass action=none header.from=cleanstormwater.com.au; dkim=pass header.d=cleanstormwater.com.au; arc=none Received: from SYZP282MB3110.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:177::5) by ME3P282MB0996.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Thu, 8 Sep 2022 08:48:58 +0000 Received: from SYZP282MB3110.AUSP282.PROD.OUTLOOK.COM ([fe80::5570:e627:ae3f:c52c]) by SYZP282MB3110.AUSP282.PROD.OUTLOOK.COM ([fe80::5570:e627:ae3f:c52c%8]) with mapi id 15.20.5588.018; Thu, 8 Sep 2022 08:48:58 +0000 From: Ming To: David Rowley CC: "pgsql-bugs@lists.postgresql.org" Subject: Re: Postgres offset and limit bug Thread-Topic: Postgres offset and limit bug Thread-Index: AQHYwyca9m+6FO6OxEmu2qrJ3WTlLK3VNcIAgAACScU= Date: Thu, 8 Sep 2022 08:48:58 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-AU X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cleanstormwater.com.au; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0b17d6c8-1d7a-4af7-f5dd-08da9176f844 x-ms-traffictypediagnostic: ME3P282MB0996:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: P7VZ2UoJTEnTzYiRNR5Pki0RSk/BgkX/sDjbkdcRJMQSQOKHc4qlO4bhrcmbqltwVkYx26Qr+G3RJhlZbWfcRfdeToEoM7gCI1l80J+dI+117lYj7bNeLrSV1Rub7wy4CatM38IaYILRRPaNJ1Es6i0XT3gMbsnWgGCz/vuiPp+Tg6CKLM7WDIom4JRcgChbsqkWv6IgT0GoEZmvrgTnVjxVxsXLOkGmKq1wkDsSNSCqreenNqAShNEsrcsMbvtY3QWFaF6Ap6A6XwbiuK3OayJFV82yjY3aGyJvbZAEr8naT4BlSMiR5XQeBOMChLfbYZCHx3wTtw6JtEfZNfFhrNEPrnln8Hkc/hjHeuwJgolNDP6LW6akSc5ipYaAy7en93w6UAgczjaqdqjBigEld8XgcWwk51SMpU5wu8jndPYVoMEZ/BvsK8J3tMRjVdGdZ1LRWmNK0BypLslQuH2YLGK098TZ8g1TOTwICsTvu7y4Cw4N0yy2g8yKH+Hy8KyO3hiDg8UIWSSizAsnS3CsacRnkV0KSYorzrB7+XvyISf91oKfimNVnVcXieAMNWZ5XrCPGRpuoet0eZnGCxkpmhV+PNL8NpjcNct8mw4odUYfm5Tst/QVvi40RXr1sr7QBtVYECFIwRTAIrAwzCmZoS5A4BCscMnI0cnI/izKBJaWq+U3jQKyOHoR6JwF35uXI+KR4qVNadhLgliy/+8SLwbW3O2HktyHiuVNB5rdaZ1xNxP2/6lrb3aa/NyooQRX0U06yNvCTzXJPYFulzby5wWx/Ennm/3Bc7kczhDGRSY= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SYZP282MB3110.AUSP282.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230016)(376002)(366004)(39830400003)(396003)(136003)(346002)(478600001)(8676002)(64756008)(83380400001)(66476007)(76116006)(66946007)(4326008)(33656002)(66556008)(91956017)(7696005)(6506007)(38070700005)(2906002)(53546011)(5660300002)(9686003)(26005)(52536014)(186003)(86362001)(66446008)(8936002)(316002)(41300700001)(122000001)(55016003)(71200400001)(38100700002)(45080400002)(6916009)(166002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?6UynmSD/Ken5tFB6UgOeQqsCTeA56fuEHkr6LkOop5YeT1s0tSqtOFty?= =?Windows-1252?Q?26jlbBTVQJVmdE+C/JW/ZJvPMvt1nP3cZ2NcKNqk24fi03Gr+p1XUnsZ?= =?Windows-1252?Q?0IOhS631mUtmNohpPl2bu+uGqf36suGL5SQ+URV45E7rXjMumAOy4p47?= =?Windows-1252?Q?i2hDNItoCwB7IIJSRpUC0mDIs549RBFT8kt+RRjFbO7z2JUzzFrt2wWQ?= =?Windows-1252?Q?ACdWoICAe3JzrU11DQfG9yZSUg0AysXd/+uMBPuEqv0P70gu23lz1vR/?= =?Windows-1252?Q?WmenwaxrMqOGyiblSsS4vxc7pbVvFvKbyBgUfjujcWpHhXB0kSixSZo8?= =?Windows-1252?Q?m39GxYAhfh+y/rBY55HxOW5Rfwrev0UCaWNSErbJbcodd4vGjWcK/Ou+?= =?Windows-1252?Q?2hOD6GiO5IYGM29JKHWsK4Yrl0jxYV38g6T3H5UcyVth4zF7KjrUy5iS?= =?Windows-1252?Q?blZ0/WDFa9nZgOLIb8vaAnuAucTz6tE6RUqoRzqzl6N9jFGkh6Pji1TO?= =?Windows-1252?Q?rQmLXSEoeX3n5+2NqP4w5MBdCaTmYkwdY2c6BABDtZUgYOM1+rw8j7q9?= =?Windows-1252?Q?h1rQsBm4MUeANDQh5f4vzjmZmJjnrC1RbjaJ3yP36HfSPt0rifvBTAbN?= =?Windows-1252?Q?82emVIPphxTEkrWXU9FwgVM9myI469favO7CiFXzCN5rK7aLdfgBoKCX?= =?Windows-1252?Q?S5+r7xZmyd3zso+d90euwQWIQvaGq2PPuB+Hj7wqWjlDF4n6zxYpu6b8?= =?Windows-1252?Q?RLdgsHsxIlEJcu/aSfbi3b42Xj9/l/2oGDFHFZjNDSoEl+yKfMF1JS8g?= =?Windows-1252?Q?MNWLKrvMTV4rITKLhPq3hDrJdlXch9BzCwPMYEa86vnsVCdZRmDzoqSJ?= =?Windows-1252?Q?12pm39HPpf05vjIYFMv1YPHhG0zDJ15F4kC/qh4pNxk+VNX/tg0j8Nvp?= =?Windows-1252?Q?4OscVKRqyqlvutUnPu+WCJgN2RnkNAq/o6xygdYZ0QGlp12YHhHdBhD6?= =?Windows-1252?Q?B8xJtyGSXXS/TxTLLvvwvnIXSbp6SsAONM0x274gNAhbFf8W1XaaB1Yq?= =?Windows-1252?Q?iFrDdWVEbLiWpD8maWS8n13GJrXxyR5ABbBs2X71iQq206gj+zGU2yM/?= =?Windows-1252?Q?e6m+5AcG9K02LO/QKmeNYhyF85Xx1hxsoLv6PJOtBqPEAevJVICLiMow?= =?Windows-1252?Q?26ELrb6H3awDw+Toirmx/ewf+8hqX8OLRTc2L9GBt/Db1PxZ15b2kGva?= =?Windows-1252?Q?6gQArC1+dI2c4OX78sWvK2ZIJBAw6cVyNTIbkH7sK7PkDTd5yYL3jod7?= =?Windows-1252?Q?vx3vk8hMtiiITJN4XKWTE4wnu5M6nMK7FM73iRiZh4RcxIXrqY8CDg03?= =?Windows-1252?Q?YMzPpspfMrMAs4g6n11Wid6aDO1ydDDs6NjkZZciXL4AUZSwAgOEzsXk?= =?Windows-1252?Q?qOP5qbsnWM0hmHMHSda9Qf3gb3ayZwE2rNNUeYdQh0uEctfpIzpmcadS?= =?Windows-1252?Q?YqR6b7nbsxphgprO4QQWy+v3VCm2yN+MqHlYxCELX+oAd7vK4jldAALl?= =?Windows-1252?Q?uEhAojszPANMH/f3zG2oYgDQE/Z6J8BrR2I6Cp7zMyol1xYZkT549zQm?= =?Windows-1252?Q?vMlL7czteNyXRqMmrHsjTvhYFhfNU4NiAE860b44q/4Gaatdazht8kdn?= =?Windows-1252?Q?/vyW3CFTJh4/Uxsz2U6t2/GZydAlhuOEDMEd9O6vcAWaLLB0pa1MzAaK?= =?Windows-1252?Q?Gp6PyGO+TrM/cv12CK8=3D?= Content-Type: multipart/alternative; boundary="_000_SYZP282MB3110CF86BB76ABA3983CC38FE5409SYZP282MB3110AUSP_" MIME-Version: 1.0 X-OriginatorOrg: cleanstormwater.com.au X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SYZP282MB3110.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 0b17d6c8-1d7a-4af7-f5dd-08da9176f844 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Sep 2022 08:48:58.3302 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 2ff9d25c-b32f-4a08-b6a3-67cc3f0595eb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wkfhzUPvIrTax4W/Uu1J/+DC8sqNXesiifd/Lvp2bp6JwfItrenismMRWszX3KdrXPOTJVuueBs45gHB/oKPAYdPmLBIU0To5PDtZuMfe7g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: ME3P282MB0996 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_SYZP282MB3110CF86BB76ABA3983CC38FE5409SYZP282MB3110AUSP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hello David, The issue is when I have limit 1 with the offset, the first record id will = be 45 (which should be 46) . (Although, it=92s ordered by path, the of is a= ctually ordered as well.) But without the limit 1 the results will be corre= ct. And when I plus one to the offset value, the actual offset will increas= e by 2. In general, the offset value with 45 is behave as offset 44. But when chang= e the value to other thing, the results will be all good. Regards, Ming Get Outlook for iOS ________________________________ From: David Rowley Sent: Thursday, September 8, 2022 6:36:04 PM To: Ming Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Postgres offset and limit bug On Thu, 8 Sept 2022 at 19:20, Ming wrote: > We recently found a strange behavior on Postgres SQL. The offset function= will not acting properly when having limit in the query. I want to confirm= that it's an existing bug or it's my syntax is wrong. Nothing looks wrong from here. Can you describe what behaviour you're expec= ting? David --_000_SYZP282MB3110CF86BB76ABA3983CC38FE5409SYZP282MB3110AUSP_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Hello David, 

The issue is when I have limit 1 with the offset, the firs= t record id will be 45 (which should be 46) . (Although, it=92s ordered by = path, the of is actually ordered as well.) But without the limit 1 the resu= lts will be correct. And when I plus one to the offset value, the actual offset will increase by 2. 

In general, the offset value with 45 is behave as offset 4= 4. But when change the value to other thing, the results will be all good.&= nbsp;

Regards, 
Ming 

From: David Rowley <dgro= wleyml@gmail.com>
Sent: Thursday, September 8, 2022 6:36:04 PM
To: Ming <ming@cleanstormwater.com.au>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.= org>
Subject: Re: Postgres offset and limit bug
 
On Thu, 8 Sept 2022 at 19:20, Ming <ming@cleans= tormwater.com.au> wrote:
> We recently found a strange behavior on Postgres SQL. The offset funct= ion will not acting properly when having limit in the query. I want to conf= irm that it's an existing bug or it's my syntax is wrong.

Nothing looks wrong from here. Can you describe what behaviour you're expec= ting?

David
--_000_SYZP282MB3110CF86BB76ABA3983CC38FE5409SYZP282MB3110AUSP_--