Skip to content

Commit

Permalink
add bindings of subscript function (#1562)
Browse files Browse the repository at this point in the history
Add bindings of supporting subscript access for user-defined types, eg.
`udf_type_value[1]`. It's supported since PostgreSQL 14.

Ref: https://www.postgresql.org/docs/current/sql-createtype.html

> The optional `subscript_function` allows the data type to be
subscripted in SQL commands. Specifying this function does not cause the
type to be considered a “true” array type; for example, it will not be a
candidate for the result type of `ARRAY[]` constructs. But if
subscripting a value of the type is a natural notation for extracting
data from it, then a `subscript_function` can be written to define what
that means. The subscript function must be declared to take a single
argument of type `internal`, and return an `internal` result, which is a
pointer to a struct of methods (functions) that implement subscripting.
The detailed API for subscript functions appears in
src/include/nodes/subscripting.h. It may also be useful to read the
array implementation in src/backend/utils/adt/arraysubs.c, or the
simpler code in contrib/hstore/hstore_subs.c. Additional information
appears in [Array Types] below.

[Array Types]:
https://www.postgresql.org/docs/current/sql-createtype.html#SQL-CREATETYPE-ARRAY

---------

Signed-off-by: usamoi <[email protected]>
  • Loading branch information
usamoi authored Feb 19, 2024
1 parent 5247de1 commit 73fefb9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pgrx-pg-sys/include/pg12.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "commands/vacuum.h"
#include "common/config_info.h"
#include "common/controldata_utils.h"
#include "executor/execExpr.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "executor/tuptable.h"
Expand All @@ -86,6 +87,8 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "nodes/print.h"
#include "nodes/replnodes.h"
#include "nodes/supportnodes.h"
Expand All @@ -103,6 +106,7 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
Expand Down
4 changes: 4 additions & 0 deletions pgrx-pg-sys/include/pg13.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "commands/vacuum.h"
#include "common/config_info.h"
#include "common/controldata_utils.h"
#include "executor/execExpr.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "executor/tuptable.h"
Expand All @@ -86,6 +87,8 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "nodes/print.h"
#include "nodes/replnodes.h"
#include "nodes/supportnodes.h"
Expand All @@ -103,6 +106,7 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
Expand Down
5 changes: 5 additions & 0 deletions pgrx-pg-sys/include/pg14.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "commands/vacuum.h"
#include "common/config_info.h"
#include "common/controldata_utils.h"
#include "executor/execExpr.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "executor/tuptable.h"
Expand All @@ -86,8 +87,11 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "nodes/print.h"
#include "nodes/replnodes.h"
#include "nodes/subscripting.h"
#include "nodes/supportnodes.h"
#include "nodes/tidbitmap.h"
#include "nodes/value.h"
Expand All @@ -103,6 +107,7 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
Expand Down
5 changes: 5 additions & 0 deletions pgrx-pg-sys/include/pg15.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "commands/vacuum.h"
#include "common/config_info.h"
#include "common/controldata_utils.h"
#include "executor/execExpr.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "executor/tuptable.h"
Expand All @@ -87,8 +88,11 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "nodes/print.h"
#include "nodes/replnodes.h"
#include "nodes/subscripting.h"
#include "nodes/supportnodes.h"
#include "nodes/tidbitmap.h"
#include "nodes/value.h"
Expand All @@ -104,6 +108,7 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
Expand Down
6 changes: 6 additions & 0 deletions pgrx-pg-sys/include/pg16.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include "commands/vacuum.h"
#include "common/config_info.h"
#include "common/controldata_utils.h"
#include "executor/execExpr.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "executor/tuptable.h"
Expand All @@ -86,10 +87,14 @@
#include "nodes/execnodes.h"
#include "nodes/extensible.h"
#include "nodes/makefuncs.h"
#include "nodes/miscnodes.h"
#include "nodes/nodeFuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/primnodes.h"
#include "nodes/print.h"
#include "nodes/replnodes.h"
#include "nodes/subscripting.h"
#include "nodes/supportnodes.h"
#include "nodes/tidbitmap.h"
#include "nodes/value.h"
Expand All @@ -105,6 +110,7 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
Expand Down

0 comments on commit 73fefb9

Please sign in to comment.