good morning!!!!

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

copy in from prepared statement is broken

parent 447bae8a
No related branches found
No related tags found
No related merge requests found
package packets
import (
"pggat/lib/fed"
"pggat/lib/util/slices"
)
type CopyData []byte
func (T *CopyData) ReadFromPacket(packet fed.Packet) bool {
if packet.Type() != TypeCopyData {
return false
}
*T = slices.Resize(*T, len(packet.Payload()))
packet.ReadBytes(*T)
return true
}
func (T *CopyData) IntoPacket() fed.Packet {
packet := fed.NewPacket(TypeCopyData, len(*T))
packet = packet.AppendBytes(*T)
return packet
}
package inst
type CopyData []byte
func (CopyData) instruction() {}
var _ Instruction = CopyData{}
package inst
type CopyDone struct{}
func (CopyDone) instruction() {}
var _ Instruction = CopyDone{}
...@@ -78,6 +78,11 @@ func (T *Runner) prepare(client *gsql.Client, until int) []Capturer { ...@@ -78,6 +78,11 @@ func (T *Runner) prepare(client *gsql.Client, until int) []Capturer {
Target: string(v), Target: string(v),
} }
client.Do(&results[i], p.IntoPacket()) client.Do(&results[i], p.IntoPacket())
case inst.CopyData:
p := packets.CopyData(v)
client.Do(&results[i], p.IntoPacket())
case inst.CopyDone:
client.Do(&results[i], fed.NewPacket(packets.TypeCopyDone))
} }
} }
......
...@@ -174,6 +174,8 @@ func TestTester(t *testing.T) { ...@@ -174,6 +174,8 @@ func TestTester(t *testing.T) {
tests.EQP8, tests.EQP8,
tests.CopyOut0, tests.CopyOut0,
tests.CopyOut1, tests.CopyOut1,
tests.CopyIn0,
tests.CopyIn1,
tests.DiscardAll, tests.DiscardAll,
); err != nil { ); err != nil {
fmt.Print(err.Error()) fmt.Print(err.Error())
......
package tests
import (
"pggat/test"
"pggat/test/inst"
)
var CopyIn0 = test.Test{
SideEffects: true,
Name: "Copy In 0",
Instructions: []inst.Instruction{
inst.SimpleQuery("CREATE TABLE test ( x integer NOT NULL, y varchar(40) NOT NULL PRIMARY KEY )"),
inst.SimpleQuery("COPY test FROM STDIN"),
inst.CopyData{49, 50, 51, 9, 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 10},
inst.CopyData{45, 51, 50, 52, 9, 103, 97, 114, 101, 116, 32, 119, 97, 115, 32, 104, 101, 114, 101, 10},
inst.CopyDone{},
inst.SimpleQuery("DROP TABLE test"),
},
}
var CopyIn1 = test.Test{
SideEffects: true,
Name: "Copy In 1",
Instructions: []inst.Instruction{
inst.SimpleQuery("CREATE TABLE test ( x integer NOT NULL, y varchar(40) NOT NULL PRIMARY KEY )"),
inst.Parse{
Query: "COPY test FROM STDIN",
},
inst.DescribePreparedStatement(""),
inst.Bind{},
inst.DescribePortal(""),
inst.Execute(""),
inst.Sync{},
inst.CopyData{49, 50, 51, 9, 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 10},
inst.CopyData{45, 51, 50, 52, 9, 103, 97, 114, 101, 116, 32, 119, 97, 115, 32, 104, 101, 114, 101, 10},
inst.CopyDone{},
inst.SimpleQuery("DROP TABLE test"),
},
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment