Skip to content

Commit

Permalink
Don't parse transaction control commands (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoor committed Mar 1, 2024
1 parent 3338bda commit 91d140a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
1 change: 1 addition & 0 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ func (p *Client) Execute(
conn.capabilities1pX(),
copyState(p.state),
nil,
true,
)
if err != nil {
return err
Expand Down
24 changes: 15 additions & 9 deletions internal/client/granularflow2pX.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,22 @@ func (c *protocolConnection) execGranularFlow2pX(
r *buff.Reader,
q *query,
) error {
ids, ok := c.getCachedTypeIDs(q)
if !ok {
return c.pesimistic2pX(r, q)
}
var cdcs *codecPair
if q.parse {
ids, ok := c.getCachedTypeIDs(q)
if !ok {
return c.pesimistic2pX(r, q)
}

cdcs, err := c.codecsFromIDsV2(ids, q)
if err != nil {
return err
} else if cdcs == nil {
return c.pesimistic2pX(r, q)
var err error
cdcs, err = c.codecsFromIDsV2(ids, q)
if err != nil {
return err
} else if cdcs == nil {
return c.pesimistic2pX(r, q)
}
} else {
cdcs = &codecPair{in: codecs.NoOpEncoder, out: codecs.NoOpDecoder}
}

return c.execute2pX(r, q, cdcs)
Expand Down
1 change: 1 addition & 0 deletions internal/client/introspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func DescribeV2(
fmt: Binary,
expCard: Many,
capabilities: userCapabilities,
parse: true,
}

r, err := conn.conn.acquireReader(ctx)
Expand Down
14 changes: 13 additions & 1 deletion internal/client/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type query struct {
args []interface{}
capabilities uint64
state map[string]interface{}
parse bool
}

func (q *query) flat() bool {
Expand Down Expand Up @@ -66,6 +67,7 @@ func newQuery(
capabilities uint64,
state map[string]interface{},
out interface{},
parse bool,
) (*query, error) {
var (
expCard Cardinality
Expand All @@ -82,6 +84,7 @@ func newQuery(
args: args,
capabilities: capabilities,
state: state,
parse: parse,
}, nil
case "Query":
expCard = Many
Expand All @@ -107,6 +110,7 @@ func newQuery(
args: args,
capabilities: capabilities,
state: state,
parse: parse,
}

var err error
Expand Down Expand Up @@ -159,7 +163,15 @@ func runQuery(
}
}

q, err := newQuery(method, cmd, args, c.capabilities1pX(), state, out)
q, err := newQuery(
method,
cmd,
args,
c.capabilities1pX(),
state,
out,
true,
)
if err != nil {
return err
}
Expand Down
20 changes: 18 additions & 2 deletions internal/client/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ func (t *Tx) execute(
cmd string,
sucessState txStatus,
) error {
q, err := newQuery("Execute", cmd, nil, txCapabilities, t.state, nil)
q, err := newQuery(
"Execute",
cmd,
nil,
txCapabilities,
t.state,
nil,
false,
)
if err != nil {
return err
}
Expand Down Expand Up @@ -155,7 +163,15 @@ func (t *Tx) Execute(
cmd string,
args ...interface{},
) error {
q, err := newQuery("Execute", cmd, args, t.capabilities1pX(), t.state, nil)
q, err := newQuery(
"Execute",
cmd,
args,
t.capabilities1pX(),
t.state,
nil,
true,
)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions internal/codecs/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ import (
types "github.com/edgedb/edgedb-go/internal/edgedbtypes"
)

var (
// NoOpDecoder is a noOpDecoder
NoOpDecoder = noOpDecoder{}

// NoOpEncoder is a noOpEncoder
NoOpEncoder = noOpEncoder{}
)

// noOpDecoder decodes empty blocks i.e. does nothing.
//
// There is one special type with type id of zero:
Expand Down

0 comments on commit 91d140a

Please sign in to comment.