GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizmodel/sql/parsejson

The SQL parser: the SQL/JSON and SQL/XML forms.

gizlang
import * as Parsejson from "gizmodel/sql/parsejson";

Methods

Parser.jsonFormat

gizlang
function Parser.jsonFormat(self: mut Parser): bool

FORMAT JSON [ENCODING name] after a SQL/JSON value or RETURNING type: JSON text is read as it is, so it is skipped.

Effects: fail, alloc.

Parser.opclassOptions

gizlang
function Parser.opclassOptions(self: mut Parser, opclass: string): void

An operator class's parameters, (name = value, ...). The text search GiST classes take siglen in 1..2024; the values are checked and not kept, as an index here keeps no signature.

Effects: fail, alloc.

Parser.xmlForm

gizlang
function Parser.xmlForm(self: mut Parser, name: string): Option<Expr>

The SQL/XML forms whose arguments are no plain list, after "xmlname(": XMLELEMENT, XMLFOREST, XMLPI, XMLROOT, XMLPARSE, XMLSERIALIZE, XMLEXISTS and XMLAGG. Names map to XML names (xml.giz xmlName). none: a plain call.

Effects: fail, read, alloc.

Parser.xmlTable

gizlang
function Parser.xmlTable(self: mut Parser): From

XMLTABLE([XMLNAMESPACES(uri AS prefix, ...),] row_path PASSING [BY REF|VALUE] doc [BY REF|VALUE] COLUMNS name {FOR ORDINALITY | type [PATH p] [DEFAULT d] [NOT NULL | NULL]}, ...): the function \u0001xmltable with arguments (row path, doc, namespaces as an array literal, then per column name, type, path, default, flags: 1 ordinality, 2 not null). Parser.xmlQuery makes the query.

Effects: fail, read, alloc.

Parser.xmlQuery

gizlang
function Parser.xmlQuery(self: mut Parser, f: From): From

The XMLTABLE item f (Parser.xmlTable) as the lateral query it stands for: the cells of every row are made once, in a one-row query (\u0001xml_pack), and a series over the rows picks them (\u0001xml_pick), cast to the column types. The column list f.columns renames the columns.

Effects: fail, alloc.

Parser.jsonValue

gizlang
function Parser.jsonValue(self: mut Parser, query: bool): Option<Expr>

JSON_VALUE and JSON_QUERY (query) with their clauses; none when no clause follows the path, which leaves the two-argument json_value and json_query of the other dialects to the generic call.

Effects: fail, read, alloc.

Parser.jsonExists

gizlang
function Parser.jsonExists(self: mut Parser): Expr

JSON_EXISTS(doc, path [PASSING ...] [TRUE | FALSE | ERROR ON ERROR]).

Effects: fail, read, alloc.

Parser.jsonSerialize

gizlang
function Parser.jsonSerialize(self: mut Parser): Expr

JSON_SERIALIZE(doc [RETURNING type] [PRETTY] [ASCII] [TRUNCATE] [ERROR | NULL ON ERROR]).

Effects: fail, read, alloc.

Parser.jsonTransform

gizlang
function Parser.jsonTransform(self: mut Parser): Expr

JSON_TRANSFORM(doc, SET | INSERT | REPLACE | APPEND | PREPEND path = value [clauses], REMOVE path, RENAME path = name, KEEP path, ... [RETURNING type]).

Effects: fail, read, alloc.

Parser.jsonTable

gizlang
function Parser.jsonTable(self: mut Parser): From

JSON_TABLE(doc, path [ON ERROR] COLUMNS (...)) as a lateral query over the rows of fnJsonRows: the top level and, left-joined under it, a source for each level of NESTED PATH columns.

Effects: fail, read, alloc.