PostgreSQL: support FOR NO KEY UPDATE and FOR KEY SHARE row-locking clauses
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
- #2788 de @abhinav-phi — fechado sem integrar
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 76/100
Direção de pesquisa
Comece localizando LockType, parse_lock e os testes de ida e volta existentes para FOR UPDATE e FOR SHARE. Adicione cobertura para os dois níveis que faltam, incluindo variantes com OF e políticas de espera; o trabalho estará concluído quando tanto os testes de parsing quanto os de ida e volta passarem nos dialetos PostgreSQL e genérico.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Summary
PostgreSQL's row-locking clause has four lock strengths: FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE and FOR KEY SHARE. sqlparser reads only FOR UPDATE and FOR SHARE. FOR NO KEY UPDATE and FOR KEY SHARE, which PostgreSQL's own referential-integrity triggers use (SELECT 1 FROM ONLY t x WHERE … FOR KEY SHARE OF x), are rejected.
Reproduction (current main, c6cec56b)
use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
Parser::parse_sql(&PostgreSqlDialect {}, "SELECT id FROM t WHERE id = 1 FOR NO KEY UPDATE").unwrap();
Parser::parse_sql(&PostgreSqlDialect {}, "SELECT id FROM t WHERE id = 1 FOR KEY SHARE OF t").unwrap();
sql parser error: Expected: one of UPDATE or SHARE, found: NO at Line: 1, Column: 35
sql parser error: Expected: one of UPDATE or SHARE, found: KEY at Line: 1, Column: 35
SELECT id FROM t WHERE id = 1 FOR SHARE OF t SKIP LOCKED parses. All of these run on PostgreSQL (checked on 17.11):
CREATE TABLE t (id int PRIMARY KEY);
SELECT id FROM t WHERE id = 1 FOR NO KEY UPDATE;
SELECT id FROM t WHERE id = 1 FOR KEY SHARE OF t;
SELECT id FROM t FOR KEY SHARE NOWAIT;
SELECT id FROM t FOR NO KEY UPDATE SKIP LOCKED;
Grammar
From https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE:
FOR lock_strength [ OF from_reference [, ...] ] [ NOWAIT | SKIP LOCKED ]
where lock_strength can be one of
UPDATE
NO KEY UPDATE
SHARE
KEY SHARE
Proposed change
Add two variants to LockType, for example NoKeyUpdate and KeyShare, displayed as NO KEY UPDATE and KEY SHARE. Parse them in parse_lock, where FOR is followed by NO KEY UPDATE or KEY SHARE, in the PostgreSQL and generic dialects. OF …, NOWAIT and SKIP LOCKED then follow as they do for the other two strengths. Round-trip tests for each strength, with and without OF and the wait policy, would cover it.
This is independent of FROM ONLY t, which the same trigger queries use and #2770 addresses.
- Linguagem predominante
- Rust
- Estrelas
- 3.5k
- Forks
- 801
- Merge médio
- 2d 19h
- PRs com merge (30d)
- 108
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/datafusion-sqlparser-rs
-
DuckDB Prolific Author
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/datafusion-sqlparser-rs#2807 ·
Mantenedores costumam responder em até 1 dia
-
DuckDB PostgreSQL Prolific Author
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/datafusion-sqlparser-rs#2803 ·
Mantenedores costumam responder em até 1 dia
-
Databricks Prolific Author Spark
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
apache/datafusion-sqlparser-rs#2801 ·
Mantenedores costumam responder em até 1 dia
-
`SHOW ... ILIKE '<pattern>'` is displayed without quotesTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaProlific Author
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
apache/datafusion-sqlparser-rs#2759 ·
Mantenedores costumam responder em até 1 dia
-
Should `DELETE + LIMIT` be supported by the generic dialect ?Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. AbertaDuckDB MySQL PostgreSQL
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
apache/datafusion-sqlparser-rs#2615 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/datafusion-sqlparser-rs
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
nervosnetwork/fiber#1723 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 69/100
Mantenedores costumam responder em até 1 dia
-
needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 71/100
pbakaus/impeccable#1314 ·
Mantenedores costumam responder em até 1 dia
-
marmite skill: `curl ... | sh` is the first install method, bypassing review and integrity checksAberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
rochacbruno/marmite#565 ·