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

codenotary / immudb / 24841644892

23 Apr 2026 02:44PM UTC coverage: 85.279% (-4.0%) from 89.306%
24841644892

push

gh-ci

web-flow
feat: v1.11.0 PostgreSQL compatibility and SQL feature expansion (#2090)

* Add structured audit logging with immutable audit trail

Introduces a new --audit-log flag that records all gRPC operations as
structured JSON events in immudb's tamper-proof KV store. Events are
stored under the audit: key prefix in systemdb, queryable via Scan and
verifiable via VerifiableGet. An async buffered writer ensures minimal
latency impact. Configurable event filtering (all/write/admin) via
--audit-log-events flag.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add PostgreSQL ORM compatibility layer and verification functions

Extend the pgsql wire protocol with immudb verification functions
(immudb_state, immudb_verify_row, immudb_verify_tx, immudb_history,
immudb_tx) accessible via standard SQL SELECT statements.

Add pg_catalog resolvers (pg_attribute, pg_index, pg_constraint,
pg_type, pg_settings, pg_description) and information_schema
resolvers (tables, columns, schemata, key_column_usage) to support
ORM introspection from Django, SQLAlchemy, GORM, and ActiveRecord.

Add PostgreSQL compatibility functions: current_database,
current_schema, current_user, format_type, pg_encoding_to_char,
pg_get_expr, pg_get_constraintdef, obj_description, col_description,
has_table_privilege, has_schema_privilege, and others.

Add SHOW statement emulation for common ORM config queries and
schema-qualified name stripping for information_schema and public
schema references.

* Implement EXISTS and IN subquery support in SQL engine

Replace the previously stubbed ExistsBoolExp and InSubQueryExp
implementations with working non-correlated subquery execution.

EXISTS subqueries resolve the inner SELECT and check if any rows
are returned. IN subqueries resolve the inner SELECT, iterate the
result set, and compare each value against the outer expression.
Both support NOT variants (NOT EXISTS, NOT IN).

Correlated subqueries (referencing outer query columns) ar... (continued)

7254 of 10471 new or added lines in 124 files covered. (69.28%)

115 existing lines in 18 files now uncovered.

44599 of 52298 relevant lines covered (85.28%)

127676.6 hits per line

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

89.47
/pkg/pgsql/errors/errors.go
1
/*
2
Copyright 2026 Codenotary Inc. All rights reserved.
3

4
SPDX-License-Identifier: BUSL-1.1
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
    https://mariadb.com/bsl11/
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 errors
18

19
import (
20
        "errors"
21
        "strings"
22

23
        bm "github.com/codenotary/immudb/pkg/pgsql/server/bmessages"
24
        "github.com/codenotary/immudb/pkg/pgsql/server/pgmeta"
25
)
26

27
var ErrUnknowMessageType = errors.New("found an unknown message type on the wire")
28
var ErrDBNotprovided = errors.New("database name not provided")
29
var ErrUsernameNotprovided = errors.New("user name not provided")
30
var ErrPwNotprovided = errors.New("password not provided")
31
var ErrDBNotExists = errors.New("selected db doesn't exists")
32
var ErrInvalidUsernameOrPassword = errors.New("invalid user name or password")
33
var ErrExpectedQueryMessage = errors.New("expected query message")
34
var ErrUseDBStatementNotSupported = errors.New("SQL statement not supported")
35
var ErrSSLNotSupported = errors.New("SSL not supported")
36
var ErrMaxStmtNumberExceeded = errors.New("maximum number of statements in a single query exceeded")
37
var ErrMessageCannotBeHandledInternally = errors.New("message cannot be handled internally")
38
var ErrMaxParamsNumberExceeded = errors.New("number of parameters exceeded the maximum limit")
39
var ErrParametersValueSizeTooLarge = errors.New("provided parameters exceeded the maximum allowed size limit")
40
var ErrNegativeParameterValueLen = errors.New("negative parameter length detected")
41
var ErrMalformedMessage = errors.New("malformed message detected")
42
var ErrMessageTooLarge = errors.New("payload message hit allowed memory boundaries")
43

44
func MapPgError(err error) (er bm.ErrorResp) {
36✔
45
        switch {
36✔
46
        case errors.Is(err, ErrDBNotprovided):
1✔
47
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
1✔
48
                        bm.Code(pgmeta.PgServerErrRejectedEstablishmentOfSqlconnection),
1✔
49
                        bm.Message(ErrDBNotprovided.Error()),
1✔
50
                        bm.Hint("please provide a valid database name or use immuclient to create a new one"),
1✔
51
                )
1✔
52
        case errors.Is(err, ErrDBNotExists):
1✔
53
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
1✔
54
                        bm.Code(pgmeta.PgServerErrRejectedEstablishmentOfSqlconnection),
1✔
55
                        bm.Message(ErrDBNotExists.Error()),
1✔
56
                        bm.Hint("please provide a valid database name or use immuclient to create a new one"),
1✔
57
                )
1✔
58
        case strings.Contains(err.Error(), "syntax error"):
5✔
59
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
5✔
60
                        bm.Code(pgmeta.PgServerErrSyntaxError),
5✔
61
                        bm.Message(err.Error()),
5✔
62
                )
5✔
63
        case strings.Contains(err.Error(), ErrUnknowMessageType.Error()):
2✔
64
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
2✔
65
                        bm.Code(pgmeta.PgServerErrProtocolViolation),
2✔
66
                        bm.Message(err.Error()),
2✔
67
                        bm.Hint("submitted message is not yet implemented"),
2✔
68
                )
2✔
UNCOV
69
        case errors.Is(err, ErrSSLNotSupported):
×
UNCOV
70
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
×
UNCOV
71
                        bm.Code(pgmeta.PgServerErrConnectionFailure),
×
UNCOV
72
                        bm.Message(err.Error()),
×
UNCOV
73
                        bm.Hint("launch immudb with a certificate and a private key"),
×
UNCOV
74
                )
×
75
        case errors.Is(err, ErrMaxStmtNumberExceeded):
2✔
76
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
2✔
77
                        bm.Code(pgmeta.PgServerErrSyntaxError),
2✔
78
                        bm.Message(err.Error()),
2✔
79
                        bm.Hint("at the moment is possible to receive only 1 statement. Please split query or use a single statement"),
2✔
80
                )
2✔
81
        case errors.Is(err, ErrParametersValueSizeTooLarge):
1✔
82
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
1✔
83
                        bm.Code(pgmeta.DataException),
1✔
84
                        bm.Message(err.Error()),
1✔
85
                )
1✔
86
        case errors.Is(err, ErrNegativeParameterValueLen):
1✔
87
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
1✔
88
                        bm.Code(pgmeta.DataException),
1✔
89
                        bm.Message(err.Error()),
1✔
90
                )
1✔
91
        case errors.Is(err, ErrMalformedMessage):
1✔
92
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
1✔
93
                        bm.Code(pgmeta.PgServerErrProtocolViolation),
1✔
94
                        bm.Message(err.Error()),
1✔
95
                )
1✔
96
        default:
22✔
97
                er = bm.ErrorResponse(bm.Severity(pgmeta.PgSeverityError),
22✔
98
                        bm.Message(err.Error()),
22✔
99
                )
22✔
100
        }
101
        return er
36✔
102
}
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