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.96) (envelope-from ) id 1w2zyr-000nro-2R for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 23:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2zyp-00FFG4-1g for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 23:07:11 +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.96) (envelope-from ) id 1w2zyp-00FFFw-0j for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 23:07:11 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2zyl-00000000RRf-3rXr for pgsql-hackers@postgresql.org; Wed, 18 Mar 2026 23:07:10 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-79a62a2bb8cso4900137b3.3 for ; Wed, 18 Mar 2026 16:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773875229; cv=none; d=google.com; s=arc-20240605; b=iXIQyAi1e9hOLhqgY149j4555dgfBgIuzxZ4OuvjZNIi5AnfMl//x38u04VJtinOxF 4GyA9gzC83Q0l7lWyjKgnDIJZWGWJHLNw8v0a6b+rtlrTb5QHwBgCAJolUHc7FMKnsM5 ZncDGa/krCS0ERJK45kNZQNMLGAsS+Fz368bQtvrqQz6HUfXE8Vyb7zZVAAtiRQQ+uih wLp4bcCuaFYakPiB3GdLgISG13c+PeXzJNDYAhELvabf27lb5aLzGG44skZOM72PPWEe Ofp+2wZrHbWyBBJBmklvoEaRzYE375AjEToeNhtKxFDKKZap9dteytHstL4fbS1OvVIq YppQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=anjvzAtIUzXNa3tqfqa8kd2njjDmoO6tpkJUhOzjkJs=; fh=nqTDt8JSFfTphBslQvXUzmqRuoLW2/uHTxVdqVkpksE=; b=OLC4syu4zCoLCMAmxCaFk4PgLwQ4J3Bx216aJ69kxXsOVy6oy6ofmz/L3na1IA+HyI xB3VQtL8bYTVsxbVSxeQTqdIFlO9h1xW8IBEqeqBnWzyHPomPznIIX3W6CQEWVh5s2lv yOEhYy+xTGYH4hveBjqHGvPeR7j/cjDWOHeph9Lx641fO5Kv91cfxVLEpwlrkEwwu4LG lrmtS8bhy4Wvb51fhJYwVQyu1lMFLt6wDBI5ordpODy+hE2m20zFjIddeD+y4Vs9AZel gNqPFNRI73ttriOxzHbIYKnHveAIMb0aB0UOktOaoxgASirIUKLPhIj4JKcIFQrZ7uM0 uscg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=percona.com; s=google; t=1773875229; x=1774480029; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=anjvzAtIUzXNa3tqfqa8kd2njjDmoO6tpkJUhOzjkJs=; b=Ow9YJoZN7ce2gBzi2KfyCi6XG1pHz/tBMbM//Aevk1CCc3bOGFMmIT4GO0MyZg43DU lipGWh8SArvcKjnvqjdMU4HTQc72TzBHoXqbybYPoENadRGLO/aKwmk0XkixPXbkjahW 5wC8fP1fMRhL4WbvdWpZBRpAeDbFE8XeSCF0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773875229; x=1774480029; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=anjvzAtIUzXNa3tqfqa8kd2njjDmoO6tpkJUhOzjkJs=; b=PUUCoXAJzS5RJus98oAUfoaXILxGuYRJgbbbopqNn/pFBzFitdbgKi7gXAepasqv6v arxD/BJvpvgAUknUR5+ns/x1ijuLmwWEPRYyIvLRTIP5/oJRbkY1R7UCnBxCUO2iJ1Vq sMAf17APuldWBtqBsRgLy1Xl32rWe2QJWuWqDuxJlmvvwvO3wBG5RRn0kpPCcLQBrgbG KFENmk3nSeFFiLXu1pNDtk1/uadERhaTPzU3R3CIuzzfVqEi1LhgKK9g5ROPXXw5/lGi MUcbXATxlJO0ih0z0xPIPuY/BR0WVRYPzXVB8DdqX/GTEHGf5d3vkMn4huDgG+gJlHqn ganA== X-Forwarded-Encrypted: i=1; AJvYcCVDcpKtGAc8ugge3Vo0kmXNW+VM6zckVGOGSpVSU+q3XcN0r330luvRjO/rM3NmoBG3uYvplxLF0xyFqYDZ@postgresql.org X-Gm-Message-State: AOJu0Yxv8tlihGU5l+Fh+jvx0VmaEFjjBGFxzpH7cvikMz4hZGw7uajd 3ACH8IqEksKLorDVkaVRzW1x26H9+eTTj5ZINk4Uw7sNnsNUjhi+CMI2mOgDH52JD76X9VP1tKe at/1/aGkHGqR0WIH8vve8gdMbWVQhBK+7U9foO9R487CvkH0sY0dTSPkNEKVl1kPyrxJF2eq8Ck 6CKb/y4m9/aTU52qi8FbUUVLf69E0ObJj1aJg4i6AMS5DFsZExohKVLbrU8fJfahlv30opDwUn6 SkR31Cvg3hwEtgML7NMZLN71pPNeMGhAQf2cuzYF3+FyylrqySVr1al+bFHp9tK+Vd2bg== X-Gm-Gg: ATEYQzzcp88QpF8Gm/m61AEW0jwF3d+p8Uy8TJ0aWUxgdtKCO0g0sH4s7lQp4rS/WR1 BAQBW/7Xs8mdqFSzGYZHx/uItwbiKeAkilbWm3RCxFe53p3+Uyc5T7j6aZs4ExklFQoHEOjIaxR T96mVqwsjbYo3JX0zhZlMbmISMqJLvi3sIaVPyB1J9Zfr3t73wVQ58AnX8M9H8zaFPqVZcFqdjX jc2cdkm+DcW66H3/o8V5E0EZPFEzDrRwvmBIWJwjYL6tSB/i3abO4Ia0mXeR7y89G10ldMCHDBa JA60x9yjLVnIdsolTkCF558tx9X/p6ROsFFRQn1N2dRpJHkUtLZNFGy7ixhkVQJtQTe5 X-Received: by 2002:a05:690c:888:b0:796:2fde:5dd4 with SMTP id 00721157ae682-79a71c619afmr49815917b3.48.1773875228696; Wed, 18 Mar 2026 16:07:08 -0700 (PDT) MIME-Version: 1.0 References: <20260311.191117.172824867943979935.ishii@postgresql.org> <20260318.204139.106185544494720182.ishii@postgresql.org> In-Reply-To: <20260318.204139.106185544494720182.ishii@postgresql.org> From: Zsolt Parragi Date: Wed, 18 Mar 2026 23:06:59 +0000 X-Gm-Features: AaiRm50XdJvUpIy4S73GYkQTS0ZFbZ_JQLYY0cwLZm24ZopGNLmKQC3_6n39JZQ Message-ID: Subject: Re: Row pattern recognition To: Tatsuo Ishii Cc: assam258@gmail.com, sjjang112233@gmail.com, vik@postgresfriends.org, er@xs4all.nl, jacob.champion@enterprisedb.com, david.g.johnston@gmail.com, peter@eisentraut.org, pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" X-CLOUD-SEC-AV-Sent: true X-CLOUD-SEC-AV-Info: percona,google_mail,monitor X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello I found one more bug, the following testcase crashes the server: CREATE TEMP TABLE t (id int, val text); INSERT INTO t VALUES (1,'A'),(2,'B'), (3,'A'),(4,'B'), (5,'A'),(6,'B'), (7,'A'),(8,'B'), (9,'X'); SELECT id, val, count(*) OVER w AS match_count FROM t WINDOW w AS ( ORDER BY id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING INITIAL PATTERN (A B (A B){1,2} A B) DEFINE A AS val = 'A', B AS val = 'B' ); Where the code does + child->min += 1; It should also increment max if it's not infinity. if (child->max != RPR_QUANTITY_INF) child->max += 1; + expr = te->expr; ... + attno_map((Node *) expr); It it okay to mutate an object in the plan cache in the executor? Wouldn't it be better to first copy it? > Adds stock trading scenario tests using realistic synthetic data > (stock.data with 1632 rows). Tests V-shape recovery, W-shape, > consecutive rises, and other common pattern matching use cases. The data file is not included in the patchset + if (wc->frameOptions & FRAMEOPTION_GROUPS) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("FRAME option GROUP is not permitted when row pattern recognition is used"), + errhint("Use: ROWS instead"), + parser_errposition(pstate, + windef->frameLocation >= 0 ? + windef->frameLocation : windef->location))); Here and at a few other places, shouldn't this use a different error code, like ERRCODE_WINDOWING_ERROR? Also a typo, the error message should say GROUPS. + elog(ERROR, "PREV/NEXT must have 1 argument but function %d has %d args", + func->funcid, nargs); Isn't this a user triggerable error, which should have a proper error code?