From df8c88af7c2c8901ef6b615c08065bca56e6f4d7 Mon Sep 17 00:00:00 2001 From: hawk Date: Thu, 28 Dec 2006 13:13:39 +0000 Subject: [PATCH] - fix LIMIT/OFFSET for null limit values, taken from PostgreSQL CVS Changed files: postgresql-LIMIT-fix.patch -> 1.1 --- postgresql-LIMIT-fix.patch | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 postgresql-LIMIT-fix.patch diff --git a/postgresql-LIMIT-fix.patch b/postgresql-LIMIT-fix.patch new file mode 100644 index 0000000..5cbe2eb --- /dev/null +++ b/postgresql-LIMIT-fix.patch @@ -0,0 +1,75 @@ +--- postgresql-8.2.0/src/backend/executor/nodeLimit.c 2006-07-26 21:31:50.000000000 +0200 ++++ postgresql-8.2.0/src/backend/executor/nodeLimit.c 2006-12-03 22:40:13.000000000 +0100 +@@ -8,7 +8,7 @@ + * + * + * IDENTIFICATION +- * $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.27 2006/07/26 19:31:50 tgl Exp $ ++ * $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.27.2.1 2006/12/03 21:40:13 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +@@ -225,20 +225,24 @@ + recompute_limits(LimitState *node) + { + ExprContext *econtext = node->ps.ps_ExprContext; ++ Datum val; + bool isNull; + + if (node->limitOffset) + { +- node->offset = +- DatumGetInt64(ExecEvalExprSwitchContext(node->limitOffset, +- econtext, +- &isNull, +- NULL)); ++ val = ExecEvalExprSwitchContext(node->limitOffset, ++ econtext, ++ &isNull, ++ NULL); + /* Interpret NULL offset as no offset */ + if (isNull) + node->offset = 0; +- else if (node->offset < 0) +- node->offset = 0; ++ else ++ { ++ node->offset = DatumGetInt64(val); ++ if (node->offset < 0) ++ node->offset = 0; ++ } + } + else + { +@@ -248,17 +252,23 @@ + + if (node->limitCount) + { +- node->noCount = false; +- node->count = +- DatumGetInt64(ExecEvalExprSwitchContext(node->limitCount, +- econtext, +- &isNull, +- NULL)); ++ val = ExecEvalExprSwitchContext(node->limitCount, ++ econtext, ++ &isNull, ++ NULL); + /* Interpret NULL count as no count (LIMIT ALL) */ + if (isNull) +- node->noCount = true; +- else if (node->count < 0) ++ { + node->count = 0; ++ node->noCount = true; ++ } ++ else ++ { ++ node->count = DatumGetInt64(val); ++ if (node->count < 0) ++ node->count = 0; ++ node->noCount = false; ++ } + } + else + { -- 2.44.0