Skip to content

Commit

Permalink
MB-53947 Detect quoted system keyspace name
Browse files Browse the repository at this point in the history
Change-Id: I1853b00cde9b0be7081705ced237c3d609e81f94
Reviewed-on: https://review.couchbase.org/c/query/+/180725
Reviewed-by: Marco Greco <marco.greco@couchbase.com>
Tested-by: Donald Haggart <donald.haggart@couchbase.com>
  • Loading branch information
dhaggart committed Oct 3, 2022
1 parent 076ae1a commit 307a634
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions inferencer/document_retrievers.go
Expand Up @@ -901,6 +901,7 @@ func MakeExpressionDocumentRetriever(context datastore.QueryContext, expr expres
}
// stream subqueries to save on caching a potentially large result-set all at once, even though it means processing this
// statement a second time
logging.Debuga(func() string { return sq.Select().String() })
edr.subquery, err = ectx.OpenStatement(sq.Select().String(), nil, nil, false, true)
if err != nil {
return nil, errors.NewInferExpressionEvalFailed(err)
Expand Down
13 changes: 12 additions & 1 deletion parser/n1ql/n1ql.go
Expand Up @@ -15,6 +15,7 @@ import (
"strings"

"github.com/couchbase/query/algebra"
"github.com/couchbase/query/datastore"
"github.com/couchbase/query/expression"
"github.com/couchbase/query/logging"
)
Expand Down Expand Up @@ -166,9 +167,15 @@ func (this *lexer) Lex(lval *yySymType) int {
}

// is it a namespace?
_, found := namespaces[lval.s]
tok := lval.s
if tok[0] == '#' {
tok = tok[1:]
}
_, found := namespaces[tok]
if !found {
return IDENT
} else {
lval.s = tok
}

// save the current token value and check the next
Expand All @@ -183,6 +190,10 @@ func (this *lexer) Lex(lval *yySymType) int {
return IDENT
}

if lval.s == datastore.GetSystemstore().Id() {
return SYSTEM
}

return NAMESPACE_ID
}

Expand Down

0 comments on commit 307a634

Please sign in to comment.