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.98.2) (envelope-from ) id 1x7TT7-00000000PA1-0OvJ for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 07:57:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x7TT6-00000008Tc4-0yTp for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 07:57:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x7TT5-00000008Tbw-3vt5 for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 07:57:11 +0000 Received: from mail-wm2-x11.google.com ([2a00:1450:4864:31::11]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x7TT4-00000000I3c-1UCE for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 07:57:11 +0000 Received: by mail-wm2-x11.google.com with SMTP id 5b1f17b1804b1-49e721b5503so4385435e9.0 for ; Fri, 18 Sep 2026 00:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789718229; x=1790323029; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rFSpCqTWBhOwfrsgDDksGwiqV4QFDBbSMOKao72uMf4=; b=Q/gVy6wY6m1xjlsl7XyMA+qZjtvLmNdJlWbKn8izVhuKtHCCnF0KOQ61UDL8rw+GbG 8wKdoQLY0H2mrZZiMXhWiKOQAzhIh4GsorIk2B8Fh/2hEbC++70K6IWwaBa5q8lGt0Dq iLfQFtRIQIygakFn23XlB15CMrFpm2Z86OwNTBKNm6DkkLlhZxDseitoZdf3+j1ioQpo +YrGNQD5DyBEN4NzvONHGSRduO5Ed88FClTFhAEkqF8ME95wptILalq6Bo0tWY4S0Fws /6pNvn/P1lOvfzF77gWdU+WNG/jQo3JLYuvcGG0oPUV2yqIrlN+aXMEgZh5I+ctAlfJQ ebwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789718229; x=1790323029; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rFSpCqTWBhOwfrsgDDksGwiqV4QFDBbSMOKao72uMf4=; b=RQlSnb54oyeET+MZVx7pFj6QcSUxqiKwJ3ZiG/R2Kvix10v2D1hkhJ3cc8INvF4wRZ ZhqGqT3hS0ZIeP5s4jy/PCrHrpl6S5M9qiDe8ZW0MbzngTbohvpcMPAcONsAxObHIVax OhjRfT5Ot7nXCXb10bjWtnmlqFaJuuS8rtrDLQ2seovXa7G6ig0+z4IXWSo6+HgPsTJV LI86dnSDqGIIzIvQ3z+GxUtVrCy6yZXgqP/8Q2dHiJVbzz3dqySB5t8Z8T/ImQ1QUE3P +ruuXvAf5ZnpUm7lKCcxx+jq7YMYEXcC37f6+XAFN7Cm7p3Bh63qBCQgi816HWUXvwW1 viSg== X-Gm-Message-State: AFuF++mF3yYyRuG0zYGJLKFvqCKEbbr0J71c6iVzp8P1Rg/7+pCLcP+a GxaATTEWSyaZtq5RKgrOUoSFZ0zhqqkhuQb7mbWzqdeAz2q3sA1jeYjvhsrSoUJz X-Gm-Gg: AYBFou2mDn7l4mDssB0uIa+wvWRl/0oC3S0jrPbSgc735rtZVlamV/1c7AbhGOd4t+i UeE7OPyrp95w66hOdSA2PgzTpsNVEogQ0oofWr6c65odwIjw91wbNccXOgQrG6YevRd6wRZXYN6 j90aaN5HsXdavRM0Uso+F4OZKuVbfT6Kdb919lvwVcEVtd8oRkCNfZD+bXxjbGnn5Cv77LM2NBr u7LwMPggrjbL6o8vmIS6wLqtoLWWv+802Rx4ElQP0aY1+V7CK3YVpQlEQ2hLEig+BzpZ6CQO5O2 AKt6/rJl2QIM6DyuIGFId8cmkXchIu/DtUSPCny0sBS6gj/+gO9M37TK7YaJij+hz6g4gOR8H8L wPEfEfveQtccWBhqxfq9BQzrUBHRfDynJjaAApF8dQQwgt89q1GT+T9ET+dxuwExnZEqJIUn8mv XAc/tYWwDPhF1mqETaaE+/fe6ELAmFooTjknbRScz4F2z45uQoN/sWrneWy59weoCOprTQRYawF 37erDwN X-Received: by 2002:a05:600c:350d:b0:49e:8184:f63b with SMTP id 5b1f17b1804b1-49fc5736085mr19023615e9.16.1789718228692; Fri, 18 Sep 2026 00:57:08 -0700 (PDT) Received: from [192.168.88.158] ([102.17.203.216]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fc7cfd3fcsm30967375e9.10.2026.09.18.00.57.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2026 00:57:07 -0700 (PDT) Message-ID: <7df7835d-a587-4d8a-a415-72e66cde5aee@gmail.com> Date: Fri, 18 Sep 2026 09:57:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: different result of regexp_instr than on Oracle To: pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Gilles Darold In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le 18/09/2026 à 07:21, Pavel Stehule a écrit : > Hi > > I got an error report for regexp_instr in Orafce. > > SELECT REGEXP_INSTR('ABC', 'A', 1, 1, 0, '', 1) AS SUBEXPR_1 > > Oracle returns 0, Postgres 1. > > Because Orafce now share this functionality with Postgres, there > should be same problem > > Is this behaviour expected? Hi Pavel, That's a good catch. I have tested orafce with your commit 546ee72 it now works as expected for Oracle compatibility. About PostgreSQL regexp_instr() behavior, I think it is expected that it returns 1, per the documentation: "the subexpr is an integer indicating which subexpression is of interest: the result identifies the position of the substring matching that subexpression. Subexpressions are numbered in the order of their leading parentheses. When subexpr is omitted or zero, the result identifies the position of the whole match regardless of parenthesized subexpressions". When no capture group are defined in the pattern, there's an implicit capture group for the whole match when subexpr is 0 or 1. contrib_regression=# SELECT REGEXP_INSTR('ABC', 'B', 1, 1, 0, '', 0) AS SUBEXPR_0;  subexpr_0 -----------          2 contrib_regression=# SELECT REGEXP_INSTR('ABC', 'B', 1, 1, 0, '', 1) AS SUBEXPR_1;  subexpr_1 -----------          2 contrib_regression=# SELECT REGEXP_INSTR('ABC', 'B', 1, 1, 0, '', 2) AS SUBEXPR_2;  subexpr_2 -----------          0 contrib_regression=# SELECT REGEXP_INSTR('ABC', 'B(C)', 1, 1, 0, '', 0) AS SUBEXPR_0;  subexpr_0 -----------          2 (1 ligne) contrib_regression=# SELECT REGEXP_INSTR('ABC', 'B(C)', 1, 1, 0, '', 1) AS SUBEXPR_1;  subexpr_1 -----------          3 Best regards, -- Gilles