From 921b993677e165607029a52e7f866bbd112345a5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 11 Apr 2011 21:32:53 -0400 Subject: Fix RI_Initial_Check to use a COLLATE clause when needed in its query. If the referencing and referenced columns have different collations, the parser will be unable to resolve which collation to use unless it's helped out in this way. The effects are sometimes masked, if we end up using a non-collation-sensitive plan; but if we do use a mergejoin we'll see a failure, as recently noted by Robert Haas. The SQL spec states that the referenced column's collation should be used to resolve RI checks, so that's what we do. Note however that we currently don't append a COLLATE clause when writing a query that examines only the referencing column. If we ever support collations that have varying notions of equality, that will have to be changed. For the moment, though, it's preferable to leave it off so that we can use a normal index on the referencing column. --- src/include/parser/parse_relation.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include/parser/parse_relation.h') diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index 50ee4dacd28..55066681f77 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -89,5 +89,6 @@ extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK); extern Name attnumAttName(Relation rd, int attid); extern Oid attnumTypeId(Relation rd, int attid); +extern Oid attnumCollationId(Relation rd, int attid); #endif /* PARSE_RELATION_H */ -- cgit v1.2.3