good morning!!!!

Skip to content
Snippets Groups Projects
Commit 26c54bd9 authored by Garet Halliday's avatar Garet Halliday
Browse files

clean up

parent 367af814
No related branches found
No related tags found
No related merge requests found
......@@ -348,133 +348,6 @@ func (c *Client) handle_function(ctx context.Context, f *protocol.FunctionCall)
return err
}
/*
func (c *Client) handle_query(ctx context.Context, q *protocol.Query) error {
// TODO extract query and do stuff based on it
_, err := q.Write(c.server.wr)
if err != nil {
return err
}
for {
var rsp protocol.Packet
rsp, err = protocol.ReadBackend(c.server.r)
if err != nil {
return err
}
switch r := rsp.(type) {
case *protocol.ReadyForQuery:
if r.Fields.Status == 'I' {
_, err = r.Write(c.wr)
if err != nil {
return err
}
return nil
}
case *protocol.CopyInResponse, *protocol.CopyOutResponse, *protocol.CopyBothResponse:
err = c.handle_copy(ctx, rsp)
if err != nil {
return err
}
continue
}
_, err = rsp.Write(c.wr)
if err != nil {
return err
}
}
}
func (c *Client) handle_function(ctx context.Context, f *protocol.FunctionCall) error {
_, err := f.Write(c.wr)
if err != nil {
return err
}
for {
var rsp protocol.Packet
rsp, err = protocol.ReadBackend(c.server.r)
if err != nil {
return err
}
_, err = rsp.Write(c.wr)
if err != nil {
return err
}
if r, ok := rsp.(*protocol.ReadyForQuery); ok {
if r.Fields.Status == 'I' {
break
}
}
}
return nil
}
func (c *Client) handle_copy(ctx context.Context, p protocol.Packet) error {
_, err := p.Write(c.wr)
if err != nil {
return err
}
switch p.(type) {
case *protocol.CopyInResponse:
outer:
for {
var rsp protocol.Packet
rsp, err = protocol.ReadFrontend(c.r)
if err != nil {
return err
}
// forward packet
_, err = rsp.Write(c.server.wr)
if err != nil {
return err
}
switch rsp.(type) {
case *protocol.CopyDone, *protocol.CopyFail:
break outer
}
}
return nil
case *protocol.CopyOutResponse:
for {
var rsp protocol.Packet
rsp, err = protocol.ReadBackend(c.server.r)
if err != nil {
return err
}
// forward packet
_, err = rsp.Write(c.wr)
if err != nil {
return err
}
switch r := rsp.(type) {
case *protocol.CopyDone:
return nil
case *protocol.ErrorResponse:
e := new(error2.Error)
e.Read(r)
return e
}
}
case *protocol.CopyBothResponse:
// TODO fix this filthy hack, instead of going in parallel (like normal), read fields serially
err = c.handle_copy(ctx, new(protocol.CopyInResponse))
if err != nil {
return err
}
err = c.handle_copy(ctx, new(protocol.CopyOutResponse))
if err != nil {
return err
}
return nil
default:
panic("unreachable")
}
}
*/
func (c *Client) Send(pkt protocol.Packet) error {
_, err := pkt.Write(c.wr)
return err
......
......@@ -226,6 +226,9 @@ func (c *ConnectionPool) GetServerInfo() []*protocol.ParameterStatus {
}
func (c *ConnectionPool) Query(client gat.Client, ctx context.Context, q string) (context.Context, error) {
// note: these deadlines aren't the time to complete the query, that should be controlled by postgres
// instead, this is the amount of time we allow the client to send extra data for a command
// (mainly so the server doesn't hang indefinitely waiting for client data)
cmdCtx, done := context.WithDeadline(ctx, time.Now().Add(1*time.Second))
c.queries <- request[string]{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment