• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codenotary / immudb / 6783902372

07 Nov 2023 11:34AM UTC coverage: 89.548% (-0.02%) from 89.571%
6783902372

push

gh-ci

jeroiraz
test(pkg/pgsql): unit testing for deallocate stmt

Signed-off-by: Jeronimo Irazabal <jeronimo.irazabal@gmail.com>

33645 of 37572 relevant lines covered (89.55%)

146027.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/pkg/pgsql/server/stmts_handler.go
1
/*
2
Copyright 2022 Codenotary Inc. All rights reserved.
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
        http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
package server
18

19
import (
20
        "regexp"
21

22
        pserr "github.com/codenotary/immudb/pkg/pgsql/errors"
23
)
24

25
var set = regexp.MustCompile(`(?i)set\s+.+`)
26
var selectVersion = regexp.MustCompile(`(?i)select\s+version\(\s*\)`)
27
var dealloc = regexp.MustCompile(`(?i)deallocate\s+\"([^\"]+)\"`)
28

29
func (s *session) isInBlackList(statement string) bool {
77✔
30
        if set.MatchString(statement) {
93✔
31
                return true
16✔
32
        }
16✔
33
        if statement == ";" {
62✔
34
                return true
1✔
35
        }
1✔
36
        return false
60✔
37
}
38

39
func (s *session) isEmulableInternally(statement string) interface{} {
51✔
40
        if selectVersion.MatchString(statement) {
53✔
41
                return &version{}
2✔
42
        }
2✔
43

44
        if dealloc.MatchString(statement) {
50✔
45
                matches := dealloc.FindStringSubmatch(statement)
1✔
46
                if len(matches) == 2 {
2✔
47
                        return &deallocate{plan: matches[1]}
1✔
48
                }
1✔
49
        }
50
        return nil
48✔
51
}
52
func (s *session) tryToHandleInternally(command interface{}) error {
3✔
53
        switch cmd := command.(type) {
3✔
54
        case *version:
2✔
55
                if err := s.writeVersionInfo(); err != nil {
3✔
56
                        return err
1✔
57
                }
1✔
58
        case *deallocate:
1✔
59
                delete(s.statements, cmd.plan)
1✔
60
                return nil
1✔
61
        default:
×
62
                return pserr.ErrMessageCannotBeHandledInternally
×
63
        }
64
        return nil
1✔
65
}
66

67
type version struct{}
68

69
type deallocate struct {
70
        plan string
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc