Skip to content

The tsquery type - #283

Merged
tamnd merged 1 commit into
mainfrom
tsq
Oct 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
tsq

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

This adds the type tsquery of text search, as tsquery.c, tsquery_op.c, tsquery_util.c and tsquery_cleanup.c have it. The functions that need a text search configuration, such as to_tsquery, and the match operator @@ are not in this change.

Changes

  • rupg-types has the new QueryItem and Value::TsQuery. A value is the list of its operands and operators in prefix order, as PostgreSQL keeps it.
  • tsquery_parse follows gettoken_query_standard and makepol: the operators !, &, |, <-> and <N>, parentheses, quotes, weights and *. It has the errors 42601, 22023 and 54000, and the error XX000 when more than 32 operators wait for an operand.
  • tsquery_deparse, tsquery_send and tsquery_recv give the text and binary forms. The receive function has the checks of tsqueryrecv.
  • tsquery_cmp gives the order of CompareTSQ. It uses the legacy CRC of PostgreSQL for each lexeme, so the order is the same as the order of PostgreSQL.
  • rupg-func has numnode, querytree, tsquery_phrase, the operators &&, ||, !!, <->, @> and <@, tsquery_cmp and the comparison operators.
  • The input of a query with no lexemes sends the NOTICE of PostgreSQL. A message of a function with a SQLSTATE of class 00 is now a NOTICE, and any other message is a WARNING. pg_input_is_valid sends no notice, as in PostgreSQL.
  • The Bind message now sends the notices of the input functions of the parameters, with the context of the parameter. Before this change, the session dropped them.
  • A constant of type tsquery in a stored expression keeps the bytes of its binary form.

Known differences

  • PostgreSQL stops a query that is too deep when it reaches max_stack_depth. Here the limit is 1000 levels, as the analyzer has for an expression. The error is the same.

Tests

  • The session test tsquery is the output of PostgreSQL 19 for the same script in a new database. It has the input and its errors, the notice, the output, the order, each function and operator, the limits, arrays, GROUP BY, pg_input_is_valid, pg_input_error_info, text and binary COPY and a query with parameters.
  • Unit tests for the parser, the order, the functions and the binary form.
  • fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 13, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. gate/G1 G1: 7 clients connect and show the schema (L1, L2). area/types Types, type I/O, casts and collations. labels Oct 13, 2026
@tamnd tamnd self-assigned this Oct 13, 2026
@tamnd
tamnd merged commit 5f04e57 into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the tsq branch October 13, 2026 10:17
@tamnd tamnd mentioned this pull request Oct 13, 2026
7 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/types Types, type I/O, casts and collations. gate/G1 G1: 7 clients connect and show the schema (L1, L2). 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