forked from postgres/postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go back to putting inference WHERE clause in parentheses
Andres felt it was important that the inference specification match the CREATE INDEX syntax as closely as possible, including having any WHERE clause follow the parentheses (containing a list of columns/expressions to be indexed). The problem with this seems to be that it more or less necessitates making both IGNORE and UPDATE fully reserved keywords in order to avoid an ambiguity, which we prefer not to do. Andres said: """ But more importantly with multiple columns for stuff like ON CONFLICT (a, b WHERE foo) it's unclear where the WHERE is actually attached to. We have that problem with aggregates and it repeatedly caused confusion. """ I don't think this quite follows, though. In fact, the CREATE INDEX syntax treats plain columns and simple function expressions in a special way -- in general, individual attributes must appear between their own parentheses. So this doesn't work: """ postgres=# insert into upsert values(3, 'Bat') on conflict (1) ignore; ERROR: 42601: syntax error at or near "1" LINE 1: insert into upsert values(3, 'Bat') on conflict (1) ignore; ^ """ But this does: """ postgres=# insert into upsert values(3, 'Bat') on conflict ((1)) ignore; """ Once you consider that the parser actually treats simple column references/functions in a special way, where the WHERE clause is attached to becomes less troubling. It also happens to be convenient to do things this way, but that is secondary. A DO UPDATE/DO NOTHING syntax seems more unappealing. This change is provisional; maybe it will be reverted when a better solution is found. But let's go this way until a better solution is actually proposed.
- Loading branch information
1 parent
0d81bd9
commit 2a5d80b
Showing
4 changed files
with
14 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters