summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2006-07-26 00:34:48 +0000
committerBruce Momjian <bruce@momjian.us>2006-07-26 00:34:48 +0000
commit085e5596541bd894328b08f0e71a6eae3bf22034 (patch)
tree6c693387bfa0fbdb81498a257fd7930f94076e4a /src/backend/parser
parent796de9c1ed3d2cfc074c3cdbe9a12c698cd53336 (diff)
downloadpostgresql-085e5596541bd894328b08f0e71a6eae3bf22034.tar.gz
Change LIMIT/OFFSET to use int8
Dhanaraj M
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_clause.c4
-rw-r--r--src/backend/parser/parse_coerce.c42
2 files changed, 42 insertions, 4 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index edd4e83bf8..2b95722530 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.153 2006/07/14 14:52:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.154 2006/07/26 00:34:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1090,7 +1090,7 @@ transformLimitClause(ParseState *pstate, Node *clause,
qual = transformExpr(pstate, clause);
- qual = coerce_to_integer(pstate, qual, constructName);
+ qual = coerce_to_integer64(pstate, qual, constructName);
/*
* LIMIT can't refer to any vars or aggregates of the current query; we
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 1e56c63d71..6aa04b7b82 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.141 2006/07/14 14:52:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.142 2006/07/26 00:34:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -821,7 +821,7 @@ coerce_to_boolean(ParseState *pstate, Node *node,
/* coerce_to_integer()
* Coerce an argument of a construct that requires integer input
- * (LIMIT, OFFSET, etc). Also check that input is not a set.
+ * Also check that input is not a set.
*
* Returns the possibly-transformed node tree.
*
@@ -857,7 +857,45 @@ coerce_to_integer(ParseState *pstate, Node *node,
return node;
}
+
+/* coerce_to_integer64()
+ * Coerce an argument of a construct that requires integer input
+ * (LIMIT, OFFSET). Also check that input is not a set.
+ *
+ * Returns the possibly-transformed node tree.
+ *
+ * As with coerce_type, pstate may be NULL if no special unknown-Param
+ * processing is wanted.
+ */
+Node *
+coerce_to_integer64(ParseState *pstate, Node *node,
+ const char *constructName)
+{
+ Oid inputTypeId = exprType(node);
+
+ if (inputTypeId != INT8OID)
+ {
+ node = coerce_to_target_type(pstate, node, inputTypeId,
+ INT8OID, -1, COERCION_ASSIGNMENT,
+ COERCE_IMPLICIT_CAST);
+ if (node == NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ /* translator: first %s is name of a SQL construct, eg LIMIT */
+ errmsg("argument of %s must be type integer, not type %s",
+ constructName, format_type_be(inputTypeId))));
+ }
+ if (expression_returns_set(node))
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ /* translator: %s is name of a SQL construct, eg LIMIT */
+ errmsg("argument of %s must not return a set",
+ constructName)));
+
+ return node;
+}
+
/* select_common_type()
* Determine the common supertype of a list of input expression types.