3178
MariaDBERRORNotableWindow FunctionsHIGH confidence

Illegal window frame end specification

Production Risk

Low — syntax error.

What this means

The window frame end bound is illegal given the frame start bound. For example, the end bound cannot be before the start bound (e.g., BETWEEN CURRENT ROW AND 2 PRECEDING).

Why it happens
  1. 1Frame end bound precedes the frame start bound (e.g., BETWEEN CURRENT ROW AND N PRECEDING).
  2. 2Frame end is UNBOUNDED PRECEDING.
How to reproduce
trigger — this will error
trigger — this will error
SELECT SUM(val) OVER (ORDER BY id ROWS BETWEEN CURRENT ROW AND 2 PRECEDING) FROM t1;

expected output

ERROR 3178 (HY000): Window frame end is illegal.

Fix

Correct the frame bound order

Correct the frame bound order
SELECT SUM(val) OVER (ORDER BY id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) FROM t1;

Why this works

The end bound must be equal to or after the start bound in row order.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3178 ER_WINDOW_FRAME_END_ILLEGAL

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors