summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane2011-04-22 21:43:18 +0000
committerTom Lane2011-04-22 21:43:18 +0000
commit9e9b9ac7d1860fbb98eb4db17a94ff25524b6447 (patch)
treeb8505f0c0aa817e1611f43d130248fa7bbb2103c /src/backend/parser
parent0cfdc1c657b7c2aa1e4524f495e84005f750ec02 (diff)
Make a code-cleanup pass over the collations patch.
This patch is almost entirely cosmetic --- mostly cleaning up a lot of neglected comments, and fixing code layout problems in places where the patch made lines too long and then pgindent did weird things with that. I did find a bug-of-omission in equalTupleDescs().
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/analyze.c10
-rw-r--r--src/backend/parser/parse_cte.c18
-rw-r--r--src/backend/parser/parse_relation.c8
-rw-r--r--src/backend/parser/parse_target.c13
4 files changed, 27 insertions, 22 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 4947a7d837e..b2032870477 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -1357,9 +1357,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
/*
* Generate dummy targetlist for outer query using column names of
- * leftmost select and common datatypes of topmost set operation. Also
- * make lists of the dummy vars and their names for use in parsing ORDER
- * BY.
+ * leftmost select and common datatypes/collations of topmost set
+ * operation. Also make lists of the dummy vars and their names for use
+ * in parsing ORDER BY.
*
* Note: we use leftmostRTI as the varno of the dummy variables. It
* shouldn't matter too much which RT index they have, as long as they
@@ -1371,7 +1371,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
targetnames = NIL;
left_tlist = list_head(leftmostQuery->targetList);
- forthree(lct, sostmt->colTypes, lcm, sostmt->colTypmods, lcc, sostmt->colCollations)
+ forthree(lct, sostmt->colTypes,
+ lcm, sostmt->colTypmods,
+ lcc, sostmt->colCollations)
{
Oid colType = lfirst_oid(lct);
int32 colTypmod = lfirst_int(lcm);
diff --git a/src/backend/parser/parse_cte.c b/src/backend/parser/parse_cte.c
index 41097263b41..ec6afd83b6c 100644
--- a/src/backend/parser/parse_cte.c
+++ b/src/backend/parser/parse_cte.c
@@ -286,10 +286,10 @@ analyzeCTE(ParseState *pstate, CommonTableExpr *cte)
else
{
/*
- * Verify that the previously determined output column types match
- * what the query really produced. We have to check this because the
- * recursive term could have overridden the non-recursive term, and we
- * don't have any easy way to fix that.
+ * Verify that the previously determined output column types and
+ * collations match what the query really produced. We have to check
+ * this because the recursive term could have overridden the
+ * non-recursive term, and we don't have any easy way to fix that.
*/
ListCell *lctlist,
*lctyp,
@@ -366,11 +366,11 @@ analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte, List *tlist)
Assert(cte->ctecolnames == NIL);
/*
- * We need to determine column names and types. The alias column names
- * override anything coming from the query itself. (Note: the SQL spec
- * says that the alias list must be empty or exactly as long as the output
- * column set; but we allow it to be shorter for consistency with Alias
- * handling.)
+ * We need to determine column names, types, and collations. The alias
+ * column names override anything coming from the query itself. (Note:
+ * the SQL spec says that the alias list must be empty or exactly as long
+ * as the output column set; but we allow it to be shorter for consistency
+ * with Alias handling.)
*/
cte->ctecolnames = copyObject(cte->aliascolnames);
cte->ctecoltypes = cte->ctecoltypmods = cte->ctecolcollations = NIL;
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 2a94f73a9ab..5359e691dd1 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -1174,7 +1174,8 @@ addRangeTableEntryForFunction(ParseState *pstate,
eref->colnames = lappend(eref->colnames, makeString(attrname));
rte->funccoltypes = lappend_oid(rte->funccoltypes, attrtype);
rte->funccoltypmods = lappend_int(rte->funccoltypmods, attrtypmod);
- rte->funccolcollations = lappend_oid(rte->funccolcollations, attrcollation);
+ rte->funccolcollations = lappend_oid(rte->funccolcollations,
+ attrcollation);
}
}
else
@@ -1902,7 +1903,8 @@ expandTupleDesc(TupleDesc tupdesc, Alias *eref,
Var *varnode;
varnode = makeVar(rtindex, attr->attnum,
- attr->atttypid, attr->atttypmod, attr->attcollation,
+ attr->atttypid, attr->atttypmod,
+ attr->attcollation,
sublevels_up);
varnode->location = location;
@@ -2009,7 +2011,7 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
/*
* get_rte_attribute_type
- * Get attribute type information from a RangeTblEntry
+ * Get attribute type/typmod/collation information from a RangeTblEntry
*/
void
get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 3f630147b0f..e6f9e36bbca 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -372,7 +372,7 @@ transformAssignedExpr(ParseState *pstate,
Oid type_id; /* type of value provided */
Oid attrtype; /* type of target column */
int32 attrtypmod;
- Oid attrcollation;
+ Oid attrcollation; /* collation of target column */
Relation rd = pstate->p_target_relation;
Assert(rd != NULL);
@@ -388,11 +388,12 @@ transformAssignedExpr(ParseState *pstate,
/*
* If the expression is a DEFAULT placeholder, insert the attribute's
- * type/typmod into it so that exprType will report the right things. (We
- * expect that the eventually substituted default expression will in fact
- * have this type and typmod.) Also, reject trying to update a subfield
- * or array element with DEFAULT, since there can't be any default for
- * portions of a column.
+ * type/typmod/collation into it so that exprType etc will report the
+ * right things. (We expect that the eventually substituted default
+ * expression will in fact have this type and typmod. The collation
+ * likely doesn't matter, but let's set it correctly anyway.) Also,
+ * reject trying to update a subfield or array element with DEFAULT, since
+ * there can't be any default for portions of a column.
*/
if (expr && IsA(expr, SetToDefault))
{