Class TsQueryHandler
A type handler for the PostgreSQL tsquery data type.
Implements
Inherited Members
Namespace: Npgsql.Internal.TypeHandlers.FullTextSearchHandlers
Assembly: Npgsql.dll
Syntax
public class TsQueryHandler : NpgsqlTypeHandler<NpgsqlTsQuery>, INpgsqlTypeHandler<NpgsqlTsQuery>, INpgsqlTypeHandler<NpgsqlTsQueryEmpty>, INpgsqlTypeHandler<NpgsqlTsQueryLexeme>, INpgsqlTypeHandler<NpgsqlTsQueryNot>, INpgsqlTypeHandler<NpgsqlTsQueryAnd>, INpgsqlTypeHandler<NpgsqlTsQueryOr>, INpgsqlTypeHandler<NpgsqlTsQueryFollowedBy>
Remarks
See https://www.postgresql.org/docs/current/static/datatype-textsearch.html.
The type handler API allows customizing Npgsql's behavior in powerful ways. However, although it is public, it should be considered somewhat unstable, and may change in breaking ways, including in non-major releases. Use it at your own risk.
Constructors
TsQueryHandler(PostgresType)
Declaration
public TsQueryHandler(PostgresType pgType)
Parameters
Type | Name | Description |
---|---|---|
PostgresType | pgType |
Methods
Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Reads a value of type TDefault
with the given length from the provided buffer,
using either sync or async I/O.
Declaration
public override async ValueTask<NpgsqlTsQuery> Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | The buffer from which to read. |
Int32 | len | The byte length of the value. The buffer might not contain the full length, requiring I/O to be performed. |
Boolean | async | If I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously. |
FieldDescription | fieldDescription | Additional PostgreSQL information about the type, such as the length in varchar(30). |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQuery> | The fully-read value. |
Overrides
ValidateAndGetLength(NpgsqlTsQuery, ref NpgsqlLengthCache, NpgsqlParameter)
Called to validate and get the length of a value of a generic NpgsqlParameter<T>.
Declaration
public override int ValidateAndGetLength(NpgsqlTsQuery value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQuery | value | |
NpgsqlLengthCache | lengthCache | |
NpgsqlParameter | parameter |
Returns
Type | Description |
---|---|
Int32 |
Overrides
ValidateAndGetLength(NpgsqlTsQueryAnd, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryAnd value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryAnd | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
ValidateAndGetLength(NpgsqlTsQueryEmpty, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryEmpty value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryEmpty | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
ValidateAndGetLength(NpgsqlTsQueryFollowedBy, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryFollowedBy value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryFollowedBy | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
ValidateAndGetLength(NpgsqlTsQueryLexeme, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryLexeme value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryLexeme | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
ValidateAndGetLength(NpgsqlTsQueryNot, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryNot value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryNot | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
ValidateAndGetLength(NpgsqlTsQueryOr, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception should be thrown. Also returns the byte length needed to write the value.
Declaration
public int ValidateAndGetLength(NpgsqlTsQueryOr value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryOr | value | |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
Int32 | The number of bytes required to write the value. |
Write(NpgsqlTsQuery, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Called to write the value of a generic NpgsqlParameter<T>.
Declaration
public override async Task Write(NpgsqlTsQuery query, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQuery | query | |
NpgsqlWriteBuffer | buf | |
NpgsqlLengthCache | lengthCache | |
NpgsqlParameter | parameter | |
Boolean | async | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Overrides
Write(NpgsqlTsQueryAnd, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryAnd value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryAnd | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Write(NpgsqlTsQueryEmpty, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryEmpty value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryEmpty | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Write(NpgsqlTsQueryFollowedBy, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryFollowedBy value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryFollowedBy | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Write(NpgsqlTsQueryLexeme, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryLexeme value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryLexeme | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Write(NpgsqlTsQueryNot, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryNot value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryNot | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Write(NpgsqlTsQueryOr, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlTsQueryOr value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlTsQueryOr | value | |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Explicit Interface Implementations
INpgsqlTypeHandler<NpgsqlTsQueryAnd>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryAnd> INpgsqlTypeHandler<NpgsqlTsQueryAnd>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryAnd> |
INpgsqlTypeHandler<NpgsqlTsQueryEmpty>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryEmpty> INpgsqlTypeHandler<NpgsqlTsQueryEmpty>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryEmpty> |
INpgsqlTypeHandler<NpgsqlTsQueryFollowedBy>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryFollowedBy> INpgsqlTypeHandler<NpgsqlTsQueryFollowedBy>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryFollowedBy> |
INpgsqlTypeHandler<NpgsqlTsQueryLexeme>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryLexeme> INpgsqlTypeHandler<NpgsqlTsQueryLexeme>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryLexeme> |
INpgsqlTypeHandler<NpgsqlTsQueryNot>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryNot> INpgsqlTypeHandler<NpgsqlTsQueryNot>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryNot> |
INpgsqlTypeHandler<NpgsqlTsQueryOr>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
async ValueTask<NpgsqlTsQueryOr> INpgsqlTypeHandler<NpgsqlTsQueryOr>.Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
Int32 | len | |
Boolean | async | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
ValueTask<NpgsqlTsQueryOr> |