Compare commits

...

2 Commits

Author SHA1 Message Date
7b5548a2c6 fix: jit failing on anon queries 2020-06-10 00:38:46 -04:00
00cfa251a2 fix: issue with jit performance 2020-06-09 19:06:16 -04:00
4 changed files with 9 additions and 29 deletions

View File

@ -85,12 +85,11 @@ type SuperGraph struct {
allowList *allow.List
encKey [32]byte
hashSeed maphash.Seed
queries map[uint64]query
queries map[uint64]*query
roles map[string]*Role
getRole *sql.Stmt
rmap map[uint64]resolvFn
abacEnabled bool
anonExists bool
qc *qcode.Compiler
pc *psql.Compiler
ge *graphql.Engine

View File

@ -172,14 +172,15 @@ func (c *scontext) resolvePreparedSQL() ([]byte, *stmt, error) {
h := maphash.Hash{}
h.SetSeed(c.sg.hashSeed)
id := queryID(&h, c.res.name, role)
q, ok := c.sg.queries[queryID(&h, c.res.name, role)]
q, ok := c.sg.queries[id]
if !ok {
return nil, nil, errNotFound
}
if q.sd == nil {
q.Do(func() { c.sg.prepare(&q, role) })
q.Do(func() { c.sg.prepare(q, role) })
if q.err != nil {
return nil, nil, err

View File

@ -494,24 +494,6 @@ func (p *Parser) parseField(f *Field) error {
return nil
}
// func (p *Parser) parseInlineFragmentFields(st *Stack, fields []Field) ([]Field, error) {
// var err error
// if p.peek(itemName) {
// p.ignore()
// // frag.On = p.vall(p.next())
// } else {
// return nil, errors.New("inline fragment: missing table name after 'on' keyword")
// }
// fields, err = p.parseNormalFields(st, fields)
// if err != nil {
// return nil, fmt.Errorf("inline fragment: %v", err)
// }
// return fields, nil
// }
func (p *Parser) parseOpParams(args []Arg) ([]Arg, error) {
for {
if len(args) >= maxArgs {

View File

@ -64,7 +64,7 @@ func (sg *SuperGraph) initPrepared() error {
return fmt.Errorf("role query: %w", err)
}
sg.queries = make(map[uint64]query)
sg.queries = make(map[uint64]*query)
list, err := sg.allowList.Load()
if err != nil {
@ -78,19 +78,17 @@ func (sg *SuperGraph) initPrepared() error {
if len(v.Query) == 0 {
continue
}
qt := qcode.GetQType(v.Query)
switch qt {
case qcode.QTQuery:
sg.queries[queryID(&h, v.Name, "user")] = query{ai: v, qt: qt}
if sg.anonExists {
sg.queries[queryID(&h, v.Name, "anon")] = query{ai: v, qt: qt}
}
sg.queries[queryID(&h, v.Name, "user")] = &query{ai: v, qt: qt}
sg.queries[queryID(&h, v.Name, "anon")] = &query{ai: v, qt: qt}
case qcode.QTMutation:
for _, role := range sg.conf.Roles {
sg.queries[queryID(&h, v.Name, role.Name)] = query{ai: v, qt: qt}
sg.queries[queryID(&h, v.Name, role.Name)] = &query{ai: v, qt: qt}
}
}
}