diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-07-22 13:30:01 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-07-22 13:30:01 -0400 |
commit | 27048980f503da22dcd289ec8342b7021c8e73e6 (patch) | |
tree | db35ce4ef2869c59c634c95446eee972910ba8ac /src/backend/optimizer/plan/planner.c | |
parent | 27cef0a56111a7a44e0d9b9a7819f7e9f4980a77 (diff) | |
download | postgresql-27048980f503da22dcd289ec8342b7021c8e73e6.tar.gz postgresql-27048980f503da22dcd289ec8342b7021c8e73e6.zip |
Re-enable error for "SELECT ... OFFSET -1".
The executor has thrown errors for negative OFFSET values since 8.4 (see
commit bfce56eea45b1369b7bb2150a150d1ac109f5073), but in a moment of brain
fade I taught the planner that OFFSET with a constant negative value was a
no-op (commit 1a1832eb085e5bca198735e5d0e766a3cb61b8fc). 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.
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index f2c9c99b7f6..e1480cda247 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -2335,7 +2335,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 @@ -2496,9 +2496,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 |