summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-07-26 19:31:51 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-07-26 19:31:51 +0000
commita998a692475845e10ba12a24c5af44b22737bd50 (patch)
treed82a26dd427190e1492a2fb21ccfe85e16c7da39 /src/backend/parser
parent5ffa0bb47a3ca975f257d665e38f2ba89625e112 (diff)
downloadpostgresql-a998a692475845e10ba12a24c5af44b22737bd50.tar.gz
Code review for bigint-LIMIT patch. Fix missed planner dependency,
eliminate unnecessary code, force initdb because stored rules change (limit nodes are now supposed to be int8 not int4 expressions). Update comments and error messages, which still all said 'integer'.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/parse_clause.c9
-rw-r--r--src/backend/parser/parse_coerce.c48
2 files changed, 32 insertions, 25 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 2b95722530..d34529c74e 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.154 2006/07/26 00:34:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.155 2006/07/26 19:31:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1074,9 +1074,12 @@ transformWhereClause(ParseState *pstate, Node *clause,
/*
* transformLimitClause -
- * Transform the expression and make sure it is of type integer.
+ * Transform the expression and make sure it is of type bigint.
* Used for LIMIT and allied clauses.
*
+ * Note: as of Postgres 8.2, LIMIT expressions are expected to yield int8,
+ * rather than int4 as before.
+ *
* constructName does not affect the semantics, but is used in error messages
*/
Node *
@@ -1090,7 +1093,7 @@ transformLimitClause(ParseState *pstate, Node *clause,
qual = transformExpr(pstate, clause);
- qual = coerce_to_integer64(pstate, qual, constructName);
+ qual = coerce_to_bigint(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 6aa04b7b82..010c704c68 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.142 2006/07/26 00:34:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.143 2006/07/26 19:31:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -780,7 +780,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node,
return (Node *) rowexpr;
}
-/* coerce_to_boolean()
+/*
+ * coerce_to_boolean()
* Coerce an argument of a construct that requires boolean input
* (AND, OR, NOT, etc). Also check that input is not a set.
*
@@ -819,8 +820,9 @@ coerce_to_boolean(ParseState *pstate, Node *node,
return node;
}
-/* coerce_to_integer()
- * Coerce an argument of a construct that requires integer input
+/*
+ * coerce_to_integer()
+ * Coerce an argument of a construct that requires integer input.
* Also check that input is not a set.
*
* Returns the possibly-transformed node tree.
@@ -857,10 +859,11 @@ 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.
+
+/*
+ * coerce_to_bigint()
+ * Coerce an argument of a construct that requires int8 input.
+ * Also check that input is not a set.
*
* Returns the possibly-transformed node tree.
*
@@ -868,34 +871,35 @@ coerce_to_integer(ParseState *pstate, Node *node,
* processing is wanted.
*/
Node *
-coerce_to_integer64(ParseState *pstate, Node *node,
- const char *constructName)
+coerce_to_bigint(ParseState *pstate, Node *node,
+ const char *constructName)
{
- Oid inputTypeId = exprType(node);
+ Oid inputTypeId = exprType(node);
if (inputTypeId != INT8OID)
{
node = coerce_to_target_type(pstate, node, inputTypeId,
- INT8OID, -1, COERCION_ASSIGNMENT,
+ 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))));
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ /* translator: first %s is name of a SQL construct, eg LIMIT */
+ errmsg("argument of %s must be type bigint, 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)));
+ (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.