PostgreSQL Source Code  git master
parse_collate.h File Reference
Include dependency graph for parse_collate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void assign_query_collations (ParseState *pstate, Query *query)
 
void assign_list_collations (ParseState *pstate, List *exprs)
 
void assign_expr_collations (ParseState *pstate, Node *expr)
 
Oid select_common_collation (ParseState *pstate, List *exprs, bool none_ok)
 

Function Documentation

◆ assign_expr_collations()

void assign_expr_collations ( ParseState pstate,
Node expr 
)

Definition at line 177 of file parse_collate.c.

178 {
180 
181  /* initialize context for tree walk */
182  context.pstate = pstate;
183  context.collation = InvalidOid;
184  context.strength = COLLATE_NONE;
185  context.location = -1;
186 
187  /* and away we go */
188  (void) assign_collations_walker(expr, &context);
189 }
static bool assign_collations_walker(Node *node, assign_collations_context *context)
@ COLLATE_NONE
Definition: parse_collate.c:58
#define InvalidOid
Definition: postgres_ext.h:36
tree context
Definition: radixtree.h:1833

References assign_collations_walker(), COLLATE_NONE, context, and InvalidOid.

Referenced by AlterPolicy(), assign_aggregate_collations(), assign_collations_walker(), assign_list_collations(), assign_ordered_set_collations(), assign_query_collations_walker(), ATPrepAlterColumnType(), buildMergedJoinVar(), coerce_fn_result_column(), cookConstraint(), cookDefault(), CreatePolicy(), CreateTriggerFiringOn(), DoCopy(), domainAddCheckConstraint(), EvaluateParams(), interpret_function_parameter_list(), test_rls_hooks_permissive(), test_rls_hooks_restrictive(), transformCallStmt(), transformCaseExpr(), transformIndexStmt(), transformJsonTableColumns(), transformPartitionBoundValue(), transformPartitionSpec(), TransformPubWhereClauses(), transformRangeTableFunc(), transformRangeTableSample(), transformRuleStmt(), and transformStatsStmt().

◆ assign_list_collations()

void assign_list_collations ( ParseState pstate,
List exprs 
)

Definition at line 155 of file parse_collate.c.

156 {
157  ListCell *lc;
158 
159  foreach(lc, exprs)
160  {
161  Node *node = (Node *) lfirst(lc);
162 
163  assign_expr_collations(pstate, node);
164  }
165 }
void assign_expr_collations(ParseState *pstate, Node *expr)
#define lfirst(lc)
Definition: pg_list.h:172
Definition: nodes.h:129

References assign_expr_collations(), and lfirst.

Referenced by assign_collations_walker(), assign_query_collations_walker(), and transformRangeFunction().

◆ assign_query_collations()

void assign_query_collations ( ParseState pstate,
Query query 
)

Definition at line 101 of file parse_collate.c.

102 {
103  /*
104  * We just use query_tree_walker() to visit all the contained expressions.
105  * We can skip the rangetable and CTE subqueries, though, since RTEs and
106  * subqueries had better have been processed already (else Vars referring
107  * to them would not get created with the right collation).
108  */
109  (void) query_tree_walker(query,
111  (void *) pstate,
114 }
#define QTW_IGNORE_CTE_SUBQUERIES
Definition: nodeFuncs.h:23
#define query_tree_walker(q, w, c, f)
Definition: nodeFuncs.h:156
#define QTW_IGNORE_RANGE_TABLE
Definition: nodeFuncs.h:26
static bool assign_query_collations_walker(Node *node, ParseState *pstate)

References assign_query_collations_walker(), QTW_IGNORE_CTE_SUBQUERIES, QTW_IGNORE_RANGE_TABLE, and query_tree_walker.

Referenced by transformDeleteStmt(), transformMergeStmt(), transformPLAssignStmt(), transformReturnStmt(), transformSelectStmt(), transformSetOperationStmt(), transformUpdateStmt(), and transformValuesClause().

◆ select_common_collation()

Oid select_common_collation ( ParseState pstate,
List exprs,
bool  none_ok 
)

Definition at line 208 of file parse_collate.c.

209 {
211 
212  /* initialize context for tree walk */
213  context.pstate = pstate;
214  context.collation = InvalidOid;
215  context.strength = COLLATE_NONE;
216  context.location = -1;
217 
218  /* and away we go */
219  (void) assign_collations_walker((Node *) exprs, &context);
220 
221  /* deal with collation conflict */
222  if (context.strength == COLLATE_CONFLICT)
223  {
224  if (none_ok)
225  return InvalidOid;
226  ereport(ERROR,
227  (errcode(ERRCODE_COLLATION_MISMATCH),
228  errmsg("collation mismatch between implicit collations \"%s\" and \"%s\"",
229  get_collation_name(context.collation),
230  get_collation_name(context.collation2)),
231  errhint("You can choose the collation by applying the COLLATE clause to one or both expressions."),
232  parser_errposition(context.pstate, context.location2)));
233  }
234 
235  /*
236  * Note: if strength is still COLLATE_NONE, we'll return InvalidOid, but
237  * that's okay because it must mean none of the expressions returned
238  * collatable datatypes.
239  */
240  return context.collation;
241 }
int errhint(const char *fmt,...)
Definition: elog.c:1319
int errcode(int sqlerrcode)
Definition: elog.c:859
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
char * get_collation_name(Oid colloid)
Definition: lsyscache.c:1035
@ COLLATE_CONFLICT
Definition: parse_collate.c:60
int parser_errposition(ParseState *pstate, int location)
Definition: parse_node.c:106

References assign_collations_walker(), COLLATE_CONFLICT, COLLATE_NONE, context, ereport, errcode(), errhint(), errmsg(), ERROR, get_collation_name(), InvalidOid, and parser_errposition().

Referenced by analyzeCTE(), assign_collations_walker(), transformSetOperationTree(), and transformValuesClause().