-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Cursors with invalid names not handled properly in SQL/pgwire mix #84261
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an ownerblathers was able to find an owner
Description
Describe the problem
If a cursor name is not a valid identifier (but can be used in double quotes), pgwire describe seems unable to find it.
To Reproduce
The following script fails with psycopg.errors.InvalidCursorName: unknown portal "1-2-3":
import os
import psycopg
with psycopg.connect(os.environ["DSN"]) as conn:
with conn.cursor("1-2-3") as cur:
cur.execute("select generate_series(1,3)")
cur.fetchall() == [(1,), (2,), (3,)]Handling this name at purely sql level has no problem:
defaultdb=> begin;
BEGIN
*defaultdb=> DECLARE "1-2-3" CURSOR FOR select generate_series(1, 3) as bar;
DECLARE CURSOR
*defaultdb=> fetch 1 from "1-2-3";
┌─────┐
│ bar │
├─────┤
│ 1 │
└─────┘
(1 row)
Environment:
- CockroachDB version 22.1.3
Jira issue: CRDB-17557
Epic CRDB-14049
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an ownerblathers was able to find an owner