Documentation
¶
Overview ¶
Package pgtext reads and writes the text forms PostgreSQL gives the values of its structured types (#2455): a range, a multirange, a composite row, an hstore and pgvector's vector. The application-database kind returns each as JSON a script reads, and accepts the same JSON as a bound parameter, which it writes back in these forms for the server to parse by the parameter's own type.
It knows only the syntax. What a range's bounds or a row's fields mean is their element types', which the caller maps.
Index ¶
- func FormatComposite(fields []*string) string
- func FormatHstore(keys []string, pairs map[string]*string) string
- func FormatMultirange(ranges []Range) string
- func FormatRange(r Range) string
- func ParseComposite(s string) ([]*string, error)
- func ParseHstore(s string) (map[string]*string, error)
- func ParseVector(s string) ([]float64, error)
- func Quote(s string) string
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatComposite ¶
FormatComposite writes fields in the form ParseComposite reads, a nil field as null.
func FormatHstore ¶
FormatHstore writes pairs in the form ParseHstore reads, a nil value as NULL. keys gives the order.
func FormatMultirange ¶
FormatMultirange writes ranges in the form ParseMultirange reads.
func FormatRange ¶
FormatRange writes r in the form ParseRange reads.
func ParseComposite ¶
ParseComposite reads a row: parentheses around fields separated by commas, an empty field being null.
func ParseHstore ¶
ParseHstore reads an hstore: "key"=>"value" pairs separated by commas, a value written NULL being null.
func ParseVector ¶
ParseVector reads a pgvector vector: brackets around numbers separated by commas.
Types ¶
type Range ¶
Range is one range value. A nil bound is unbounded (infinite); Empty is the range with no points, whose bounds are not meaningful.
func ParseMultirange ¶
ParseMultirange reads a multirange: braces around ranges separated by commas.
func ParseRange ¶
ParseRange reads a range as PostgreSQL writes it: empty, or a bracket or parenthesis, the lower bound, a comma, the upper bound and a closing bracket or parenthesis, a missing bound being unbounded.