The `xml` type does not exist, and `xpath()` is not found
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 73
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 129
Description
On DoltgreSQL 1.3.1 the `xml` type does not exist, and neither does the `xpath` function. A cast to `xml`,
a table column of type `xml`, and a call to `xpath` are each refused:
```
ERROR: unable to resolve type `xml`
ERROR: type "xml" does not exist
ERROR: function: 'xpath' not found
```
PostgreSQL 18.6 runs the same three statements: it returns `x`, creates the table, and returns `{x}`.
## Reproduction
[`repro.sql`](https://github.com/Reliable-Collaboration/repro-doltgresql-bug-xpath/blob/main/repro.sql):
```sql
-- A value of type xml.
SELECT 'x'::xml AS doc;
-- A table column of type xml.
CREATE TABLE t (doc xml);
-- The xpath function over an xml value.
SELECT xpath('/a/text()', 'x'::xml);
```
## Expected behavior
All three statements succeed. This is what PostgreSQL 18.6 does:
```
-- A value of type xml.
SELECT 'x'::xml AS doc;
doc
----------
x
(1 row)
-- A table column of type xml.
CREATE TABLE t (doc xml);
CREATE TABLE
-- The xpath function over an xml value.
SELECT xpath('/a/text()', 'x'::xml);
xpath
-------
{x}
(1 row)
```
## Actual behavior
All three statements fail. This is what DoltgreSQL 1.3.1 does:
```
-- A value of type xml.
SELECT 'x'::xml AS doc;
psql:/tmp/repro.sql:2: ERROR: unable to resolve type `xml`
-- A table column of type xml.
CREATE TABLE t (doc xml);
psql:/tmp/repro.sql:5: ERROR: type "xml" does not exist
-- The xpath function over an xml value.
SELECT xpath('/a/text()', 'x'::xml);
psql:/tmp/repro.sql:8: ERROR: function: 'xpath' not found
```
## Run it
A runnable reproduction is at https://github.com/Reliable-Collaboration/repro-doltgresql-bug-xpath. 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-xpath.git
cd repro-doltgresql-bug-xpath
./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:
- Without the cast, `SELECT xpath('/a/text()', 'x');` answers the same `function: 'xpath' not found`,
and so does `SELECT pg_catalog.xpath('/a/text()', 'x');`. PostgreSQL returns `{x}` for both.
- `SELECT xpath_exists('/a', 'x'::xml);` answers `function: 'xpath_exists' not found`. PostgreSQL
returns `t`.
- Over a `text` column, `CREATE VIEW v2 AS SELECT id, xpath('/a/text()', doc::xml) AS x FROM t2;` answers
`function: 'xpath' not found`, and `CREATE VIEW v3 AS SELECT id, doc::xml AS d FROM t2;` answers
``unable to resolve type `xml` ``. PostgreSQL creates both views.
- Spelled `pg_catalog.xml`, the type name is accepted, but the value is not `xml`:
`SELECT pg_typeof('x'::pg_catalog.xml);` answers `unknown`, and `SELECT ''::pg_catalog.xml AS malformed;`
returns `` without an error. PostgreSQL answers `xml`, and refuses `''` with `invalid XML content`.
- `CREATE TABLE t4 (doc pg_catalog.xml);` succeeds, and the column's `data_type` in
`information_schema.columns` is `unknown`; `INSERT INTO t4 VALUES ('');` then succeeds. On PostgreSQL the
column's `data_type` is `xml`, and the insert fails with `invalid XML content`.
- `SELECT XMLPARSE(DOCUMENT 'x');` answers `function: 'xmlparse' not found`; `xml_is_well_formed`,
`xml_is_well_formed_document`, `xmlconcat` and `xmlcomment` answer the same error with their own names.
PostgreSQL runs all five.
- `SELECT xmlelement(name a, 'x');` answers `at or near "a": syntax error`, and
`SELECT * FROM XMLTABLE('/a' PASSING 'x' COLUMNS v text PATH 'text()');` answers
`at or near "passing": syntax error`. PostgreSQL returns `x` and `x`.
- `SELECT typname FROM pg_type WHERE typname = 'xml';` returns no row (PostgreSQL: `xml`, oid 142).
## Possibly related
None found.
## 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.