Skip to content

Define binary transfer for custom types dynamically on PGConnection #2554

Closed

Description

@sebasbaumh

Feature request
I would like to be able to specify binary transfer for custom data types dynamically on a PGConnection instance.
Similar to what I can do to add handling for custom types using PGConnection.addDataType.

Use case
The main use case for this will be connections that I did not create on my own (where I could set properties).
So for example if the PGConnection I use is not created by my application itself, but e.g. by the application server that runs it.

And I would like to allow using binary transfer for PostGIS geometries using the library postgis-java-ng, which already allows adding the handled types dynamically to a PGConnection.

Scope
This function should be optional and not always enforce binary transfer.
In contrast to #1884 I do not want to enable this behavior automatically.

I will look deeper into the code for enabling the binary transfer and might try to provide an according pull request.

Activity

  1. sebasbaumh commented on Jun 24, 2022

    @sebasbaumh
    ContributorAuthor

    While looking at the source code, I just noted that it is possible to adjust the binary transferred oids by
    using QueryExecutor.setBinaryReceiveOids or QueryExecutor.setBinarySendOids.
    And the QueryExecutor itself can be retrieved using BaseConnection.getQueryExecutor().

    The only issue with this is that BaseConnection (extending PGConnection) explicitly states that Application code should not depend on this interface.

  2. sebasbaumh commented on Jun 24, 2022

    @sebasbaumh
    ContributorAuthor

    I created a pull request #2556 to be able to get existing oids for binary sending and receiving from the QueryExecutor as well as add new oids to it.
    This should be sufficient for adding single oids for custom types that should support binary transfers.

    And I refrained from changing PGConnection as it is sufficient to change types in the QueryExecutor as there is only a single instance per connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions