MagicStack / MagicStack/asyncpg

When using Redshift - PostgresSyntaxError: syntax error at or near "ORDER" - in query with no "ORDER"

Aperta
#1,009 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
8.1k
Fork
469
Merge medio
18m
PR unite (30g)
4

Descrizione

  • asyncpg version: asyncpg==0.27.0.
  • PostgreSQL version: PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.46987.
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : I am using Amazon Redshift. I could not reproduce the issue with potgres:9.0 Docker image.
  • Python version: Python 3.9.12.
  • Platform: Windows 10 Pro, 22H2, 19045.2604.
  • Do you use pgbouncer?: No.
  • Did you install asyncpg with pip?: Yes.
  • If you built asyncpg locally, which version of Cython did you use?: -
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : Have not tried uvloop.

Running this snippet:

options = ConnectionOptions()

sslctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
sslctx.check_hostname = False
sslctx.verify_mode = ssl.CERT_NONE

connection = await asyncpg.connect(options.dsn, ssl=sslctx)

try:
    query = "select 'all' = any($1::text[])"
    await connection.fetch(query, ["all"])

finally:
    await connection.close()

I get this exception:

asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "ORDER"

I am wondering, where the "syntax error at or near "ORDER" comes from, as there is no "ORDER" in the original query.

If asyncpg does not rewrite queries in any way, and the query passed to fetch is forwarded to the database without modification (https://github.com/MagicStack/asyncpg/issues/434#issuecomment-910474719, https://github.com/MagicStack/asyncpg/discussions/859#discussioncomment-1742492) - where does the "ORDER" come from?

Can this issue be worked around, or I should abandon asyncpg as a Redshift client? I do understand that Redshift is not officially supported, but this client is very good otherwise.

I was not able to reproduce the error with the postgres:9.0 instance (the oldest I was able to find quickly). The same (except ssl=False) snippet works without errors.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal punto di ingresso connection.fetch e dalla query riprodotta select 'all' = any($1::text[]), quindi confronta il suo comportamento su Redshift con quello dell’immagine Docker PostgreSQL segnalata. Determina se l’errore di sintassi ha origine in asyncpg o in Redshift e documenta un workaround confermato oppure la limitazione di compatibilità.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
postgresql, python
Ambito
databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.