mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Re-enable error for "SELECT ... OFFSET -1".
The executor has thrown errors for negative OFFSET values since 8.4 (see commitbfce56eea4
), but in a moment of brain fade I taught the planner that OFFSET with a constant negative value was a no-op (commit1a1832eb08
). Reinstate the former behavior by only discarding OFFSET with a value of exactly 0. In passing, adjust a planner comment that referenced the ancient behavior. Back-patch to 9.3 where the mistake was introduced.
This commit is contained in:
parent
f59c8eff7d
commit
6306d07122
@ -2127,7 +2127,7 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction,
|
||||
{
|
||||
*offset_est = DatumGetInt64(((Const *) est)->constvalue);
|
||||
if (*offset_est < 0)
|
||||
*offset_est = 0; /* less than 0 is same as 0 */
|
||||
*offset_est = 0; /* treat as not present */
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2288,9 +2288,8 @@ limit_needed(Query *parse)
|
||||
{
|
||||
int64 offset = DatumGetInt64(((Const *) node)->constvalue);
|
||||
|
||||
/* Executor would treat less-than-zero same as zero */
|
||||
if (offset > 0)
|
||||
return true; /* OFFSET with a positive value */
|
||||
if (offset != 0)
|
||||
return true; /* OFFSET with a nonzero value */
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user