Skip to content

Cursors with invalid names not handled properly in SQL/pgwire mix #84261

@dvarrazzo

Description

@dvarrazzo

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

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an owner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions