`convert_from()` is not found
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 73
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 152
Description
On DoltgreSQL 1.3.1, `convert_from`, the function that turns bytes in a named encoding into text, does not
exist, while its inverse `convert_to` works. `SELECT convert_from('\x68656c6c6f'::bytea, 'UTF8')` answers:
```
ERROR: function: 'convert_from' not found
```
PostgreSQL 18.6 returns `hello`.
## Reproduction
[`repro.sql`](https://github.com/Reliable-Collaboration/repro-doltgresql-bug-convert-from/blob/main/repro.sql):
```sql
-- convert_to: text to bytes in the UTF8 encoding.
SELECT convert_to('hello', 'UTF8');
-- convert_from: the same bytes back to text.
SELECT convert_from('\x68656c6c6f'::bytea, 'UTF8');
```
## Expected behavior
Both statements succeed: `convert_to` turns `hello` into the bytes `\x68656c6c6f`, and `convert_from` turns
those bytes back into `hello`. This is what PostgreSQL 18.6 does:
```
-- convert_to: text to bytes in the UTF8 encoding.
SELECT convert_to('hello', 'UTF8');
convert_to
--------------
\x68656c6c6f
(1 row)
-- convert_from: the same bytes back to text.
SELECT convert_from('\x68656c6c6f'::bytea, 'UTF8');
convert_from
--------------
hello
(1 row)
```
## Actual behavior
`convert_to` returns the same bytes as on PostgreSQL, but `convert_from` is not found. This is what
DoltgreSQL 1.3.1 does:
```
-- convert_to: text to bytes in the UTF8 encoding.
SELECT convert_to('hello', 'UTF8');
convert_to
--------------
\x68656c6c6f
(1 row)
-- convert_from: the same bytes back to text.
SELECT convert_from('\x68656c6c6f'::bytea, 'UTF8');
psql:/tmp/repro.sql:5: ERROR: function: 'convert_from' not found
```
## Run it
A runnable reproduction is at https://github.com/Reliable-Collaboration/repro-doltgresql-bug-convert-from. Its script runs the test on PostgreSQL and DoltgreSQL in throwaway containers and prints the two outputs side by side:
```sh
git clone https://github.com/Reliable-Collaboration/repro-doltgresql-bug-convert-from.git
cd repro-doltgresql-bug-convert-from
./repro.sh
```
## Other observations
Each was run with `psql` on DoltgreSQL 1.3.1 and on PostgreSQL 18.6, in containers from the same images:
- Every other call of `convert_from` tried answers the same `function: 'convert_from' not found`:
`SELECT convert_from('\x68656c6c6f', 'UTF8');` with an untyped argument,
`SELECT pg_catalog.convert_from('\x68656c6c6f'::bytea, 'UTF8');`, the encoding names `'LATIN1'` and
`'utf-8'`, and `SELECT convert_from(convert_to('hello', 'UTF8'), 'UTF8');`. PostgreSQL returns `hello` for
each.
- `SELECT convert_from('\xe9'::bytea, 'LATIN1');` answers the same error. PostgreSQL returns `é`.
- Over a `bytea` column, `SELECT id, convert_from(b, 'UTF8') FROM t;` and
`CREATE VIEW v AS SELECT id, convert_from(b, 'UTF8') AS s FROM t;` answer the same error. PostgreSQL
returns `hello` and creates the view.
- These match PostgreSQL: `convert_to(chr(233), 'LATIN1')` returns `\xe9` and `convert_to(chr(233), 'UTF8')`
returns `\xc3a9`; `encode` with `'escape'`, `'hex'` and `'base64'` returns `hello`, `68656c6c6f` and
`aGVsbG8=`; `SELECT length('\x68656c6c6f'::bytea);` returns `5`.
- `decode` is not found either: `SELECT decode('68656c6c6f', 'hex');`, `SELECT decode('aGVsbG8=', 'base64');`
and `SELECT decode('hello', 'escape');` answer `function: 'decode' not found`. PostgreSQL returns
`\x68656c6c6f` for each.
- `SELECT convert('\x68656c6c6f'::bytea, 'UTF8', 'LATIN1');` answers `function: 'convert' not found`, and
`SELECT length('\x68656c6c6f'::bytea, 'UTF8');` answers `function length(bytea, unknown) does not exist`.
PostgreSQL returns `\x68656c6c6f` and `5`.
- `SELECT proname FROM pg_proc WHERE proname IN ('convert_from', 'convert_to', 'convert', 'encode', 'decode') ORDER BY 1;`
returns `(0 rows)`, including for the two functions that work. PostgreSQL returns all five. Possibly related:
[dolthub/doltgresql#3190](https://github.com/dolthub/doltgresql/issues/3190).
- `convert_to` was added in [dolthub/doltgresql#3189](https://github.com/dolthub/doltgresql/pull/3189). The
feature list in [dolthub/doltgresql#3099](https://github.com/dolthub/doltgresql/issues/3099) marks
`convert_to` done and does not name `convert_from`.
## Possibly related
#3099 (open) tracks missing functions and marks `convert_to` as added; it does not list `convert_from`. #3190 (open) covers DoltgreSQL's function catalog not listing these functions.
## Environment
- DoltgreSQL 1.3.1: image `dolthub/doltgresql:1.3.1`, digest
`sha256:6c85cb1f35beabf47f094336a420255130b841b1645f36d79ef046276af36851`. Its bundled `psql` is 17.11.
- PostgreSQL 18.6: image `postgres:18.6-bookworm`, digest
`sha256:1c59e2c3c818eaa0f0628f695b36e7c9e362d6b219b36a54a32df645cbd7e1af`. Its `psql` is 18.6.
- Reproduced on 2026-09-11 (UTC) with Docker 29.7.2 on Ubuntu 26.04.1 LTS under WSL 2 (Linux
6.18.33.2-microsoft-standard-WSL2, x86_64).
Contributor guide
Assessment
This issue has not been assessed yet.