select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / CLIENT CONNECTION DEFAULTS

Sets whether DOCUMENT or CONTENT is implicit when converting between XML and character string values.

Type
enum
Context
user
Measured default
content
Unit
Metadata snapshot
18
Allowed values
content, document

Definition PG 18 manual

Sets whether DOCUMENT or CONTENT is implicit when converting between XML and character string values. See Section 8.13 for a description of this. Valid values are DOCUMENT and CONTENT. The default is CONTENT.

According to the SQL standard, the command to set this option is

SET XML OPTION { DOCUMENT | CONTENT };

This syntax is also available in PostgreSQL.

Measured default history
Version intervalDefault
9.0 – 19content
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

xmloption sets whether XML data in implicit parsing and serialization operations is to be considered as documents or content fragments. CONTENT permits XML fragments while DOCUMENT requires a single well-formed XML document, changing implicit casts and serialization behavior.

xmloption is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

It changes representation, parsing, or locale behavior at the client boundary rather than physical storage. Coordinate it with the other locale and formatting settings and with driver-native binary or typed protocols.

Operational considerations

Changing xmloption in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.

Assuming a presentation setting changes stored values or server-side type semantics.

Changing a role or database default without testing text-parsing clients, exports, and pooled sessions.

Changing xmloption globally without a rollback plan and a client or operational compatibility test.

Workload guidance

OLAP: Pin xmloption for export, reporting, and reproducible analytical jobs; prefer explicit SQL formatting when a file or API has a durable schema.

OLTP: Treat xmloption as an application contract, not a performance knob. Standardize it per role or connection pool and keep wire formats explicit where clients parse text.

SMALL: Keep the upstream or locale-derived value unless a client requires another one. A smaller server gains no capacity from changing xmloption.

Related entries

Further reading

Definition snapshot: english-manuals:f3a4fbc94f4bacf3dfff79765f9… · English manual source