-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle copy from stdin
query
#64
Comments
馃憢 Hi @hectorj, thanks for opening an issue! I indeed have not yet included support for the COPY protocol flow inside psql-wire. It is a feature I am interested in implementing. I would like to try to keep the server implementation as simple as possible, with the possibility of defining more complex flows if needed. It appears that the COPY protocol flow is not backwards compatible and would require its own handler methods. The COPY handler could accept a reader and writer interface, allowing the server to read or write rows from/to the client. Support for text/binary values has been implemented inside the encoder. It is possible to easily define the encoding type while reading incoming messages. It would be great if you could help me set up a small example project using the COPY protocol. I would like to inspect the packages being sent back and forth between the client and server using the psql-proxy CLI. |
I tried setting up an example here: https://github.com/hectorj/psql-proxy-copy-example But I keep hitting this error message when connecting to the proxy: I don't have this issue with |
Ah, this might be a bug. This error is often thrown when an unexpected message is read from the client. I will take a look at this later today. The psql proxy is unaware of the message flows. It might be that untyped messages are send during the COPY protocol flow. |
Edit: completely wrong |
Edit : removed because of many false assumptions |
OK, I just had to set the Now here are the full proxy logs:
My example repo is now functional if you want to try it. |
Hi @hectorj thanks for the update! I apologize, but I'm currently dealing with some personal matters this week that require my attention. I will take a look at this issue as soon as possible. It seems the COPY flow simply has to be implemented for the messages to be handled correctly. |
Hey, no worry: you don't have to apologize for not putting benevolent work first ^^ I'm actually testing another lower-level approach (closer to what psql-proxy does) for my project, so there is really no hurry at all. |
Hi, and first of all: thank you for your work! 馃檪
I am trying to use pgx's
CopyFrom
method on a server created withpsql-wire
.Reading the spec here https://www.postgresql.org/docs/15/protocol-flow.html#PROTOCOL-COPY, the server is supposed to send a
CopyInResponse
message before receiving the data via multipleCopyData
messages, ending with aCopyDone
message.I don't see a way to handle that currently inside a
ParseFn
, but maybe I missed something?The query reaches my parser, and the
wire.PreparedStatementFn
is called just after, but then we can't properly process the whole operation.Calling
writer.Complete("CopyInResponse")
makes the pgx client return without error, but with 0 rows inserted (and we never see the data to be copied server-side).I'm not sure how this should be handled.
Maybe a different handler? That would make
psql-wire
responsible for parsing and recognizing acopy from
query, I'm not sure that's great.Or change the
wire.DataWriter
to be able to send theCopyInResponse
and read the next messages? That may be better.This may be a "won't fix", but I wanted to at least have a discussion about it.
Even if this hurdle falls, I know
pgx
forces the binary format oncopy from
so I won't be out of the woods yet 馃槃The text was updated successfully, but these errors were encountered: