Skip to content

Make the functions of information_schema with a query body - #231

Merged
tamnd merged 1 commit into
mainfrom
sqlbodies
Oct 9, 2026
Merged

tamnd merged 1 commit into
mainfrom
sqlbodies

Conversation

@tamnd

@tamnd tamnd commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Part of #3.

rupg now makes the last two functions of information_schema.sql: _pg_expandarray and _pg_index_position. Before this change, the setup skipped them, because CREATE FUNCTION took only a RETURN body. The views of information_schema call these two functions, so this is a step to the views.

_pg_expandarray has a query in a string, SETOF record, polymorphic OUT parameters, ROWS and SUPPORT. _pg_index_position has a query in BEGIN ATOMIC. The analyzer reads the body again for each call with the actual types of the arguments, so a polymorphic argument has its actual type in the query.

What changes

  • CREATE FUNCTION takes OUT, INOUT and TABLE parameters, SETOF, ROWS, SUPPORT, a body in a string and a body in BEGIN ATOMIC. The result type comes from the OUT parameters as in CreateFunction.
  • A query body gets the checks of check_sql_fn_retval: the number of columns and an assignment cast of each column to the type of the result column.
  • The catalog function has proretset, prosupport, proallargtypes, proargmodes and prosrc, and pg_proc shows them.
  • The executor runs a query body. A function that returns a set gives the rows of the query, and another function gives the first column of the first row, or null.
  • The executor keeps a body for each function and each list of argument types.
  • A view and a function body record a dependency on each function that is not pinned.
  • The setup gives the two functions the OIDs 13351 and 13352 of PostgreSQL 19.

Test

  • New session test sql_bodies. Its expected output is the output of PostgreSQL 19 for the same script in a new database. It calls the functions in FROM, in the target list and with LATERAL, with null, empty, two dimension and int2vector arguments. It also reads the rows of pg_proc and pg_depend and the output of pg_get_function_arguments and pg_get_function_result.
  • srvtest passed on server1: fmt, layers, style, clippy, all the workspace tests, the generated file checks and the docs.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 9, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. kind/compat A difference from PostgreSQL 19 at one of the five levels L1 to L5. area/sql The grammar, the lexer, the analyzer and the rewriter. labels Oct 9, 2026
@tamnd tamnd self-assigned this Oct 9, 2026
@tamnd
tamnd merged commit 949a944 into main Oct 9, 2026
5 checks passed
@tamnd
tamnd deleted the sqlbodies branch October 9, 2026 20:04
@tamnd tamnd mentioned this pull request Oct 9, 2026
4 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sql The grammar, the lexer, the analyzer and the rewriter. kind/compat A difference from PostgreSQL 19 at one of the five levels L1 to L5. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant