cockroachdb / cockroachdb/cockroach

VARCHAR Column Vectors and VARCHAR constants/literals are incorrectly being shown as `text` type.

Open
#148,473 2 comments 0 reactions 0 assignees View on GitHub
A-sql-pgcompat branch-release-23.1 C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

Column vectors from a VARCHAR column are being incorrectly shown as the `text` type with `pg_typeof(VARCHAR_COLUMN)`.

SQL Literals / Constants also have this same issue.

**To Reproduce**

To reproduce:
`CREATE TABLE t (v VARCHAR);`
`INSERT INTO t VALUES ('testvarchar');`
`SELECT pg_typeof(v) FROM t;`

Result:
```
pg_typeof
-------------
text
(1 row)
```

and for the SQL literal/constant case, we can reproduce with:
`SELECT pg_typeof('test'::VARCHAR);`

Result:
```
pg_typeof
-------------
text
(1 row)
```

**Expected behavior**

The expected behavior should align with PostgreSQL's `pg_typeof()` behavior, which returns:

```
pg_typeof
-------------------
character varying
(1 row)
```

for both of these scenarios.

**Environment:**

The latest CRDB master branch exhibits this issue.

Jira issue: CRDB-51633

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.