• 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

32.79
/pkg/pgsql/sys/types.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 sys
18

19
import (
20
        "fmt"
21

22
        "github.com/codenotary/immudb/embedded/sql"
23
)
24

25
// pgTypeOIDForSQLType maps immudb's internal SQLValueType to the
26
// canonical PostgreSQL type OID the wire protocol returns for that
27
// column. Matches the map in pkg/pgsql/server/immudb_functions.go
28
// (pgTypeOIDByName) so the two layers stay consistent.
29
func pgTypeOIDForSQLType(t sql.SQLValueType) int64 {
28✔
30
        switch t {
28✔
31
        case sql.IntegerType:
8✔
32
                return 20 // int8 — safe for all immudb integers, which are int64
8✔
33
        case sql.BooleanType:
7✔
34
                return 16 // bool
7✔
35
        case sql.VarcharType:
12✔
36
                return 1043 // varchar
12✔
NEW
37
        case sql.UUIDType:
×
NEW
38
                return 2950 // uuid
×
NEW
39
        case sql.BLOBType:
×
NEW
40
                return 17 // bytea
×
41
        case sql.Float64Type:
1✔
42
                return 701 // float8
1✔
NEW
43
        case sql.TimestampType:
×
NEW
44
                return 1114 // timestamp (no tz)
×
NEW
45
        case sql.JSONType:
×
NEW
46
                return 3802 // jsonb
×
NEW
47
        case sql.AnyType:
×
NEW
48
                return 2276 // "any" — matches PG's polymorphic pseudo-type
×
NEW
49
        default:
×
NEW
50
                return 0 // unknown — clients will use text fallback
×
51
        }
52
}
53

54
// pgTypeNameForSQLType returns the PostgreSQL type name for a given
55
// immudb SQLValueType, as emitted by format_type(oid, typmod). Used
56
// both by the pg_attribute scan (for PG_catalog niceties) and by the
57
// format_type built-in function once it's wired up.
58
//
59
// maxLen is respected only for VARCHAR: format_type emits
60
// `character varying(N)` when a typmod is supplied, matching PG's
61
// conventions for what \d shows.
NEW
62
func pgTypeNameForSQLType(t sql.SQLValueType, maxLen int) string {
×
NEW
63
        switch t {
×
NEW
64
        case sql.IntegerType:
×
NEW
65
                return "bigint"
×
NEW
66
        case sql.BooleanType:
×
NEW
67
                return "boolean"
×
NEW
68
        case sql.VarcharType:
×
NEW
69
                if maxLen > 0 {
×
NEW
70
                        return fmt.Sprintf("character varying(%d)", maxLen)
×
NEW
71
                }
×
NEW
72
                return "character varying"
×
NEW
73
        case sql.UUIDType:
×
NEW
74
                return "uuid"
×
NEW
75
        case sql.BLOBType:
×
NEW
76
                return "bytea"
×
NEW
77
        case sql.Float64Type:
×
NEW
78
                return "double precision"
×
NEW
79
        case sql.TimestampType:
×
NEW
80
                return "timestamp without time zone"
×
NEW
81
        case sql.JSONType:
×
NEW
82
                return "jsonb"
×
NEW
83
        case sql.AnyType:
×
NEW
84
                return "any"
×
NEW
85
        default:
×
NEW
86
                return "text" // conservative fallback — psql still renders something
×
87
        }
88
}
89

90
// pgTypeLenForSQLType returns the PostgreSQL attlen value for
91
// pg_attribute. Fixed-width types report their byte size; variable-
92
// width types report -1 (PG's convention).
93
func pgTypeLenForSQLType(t sql.SQLValueType) int64 {
28✔
94
        switch t {
28✔
95
        case sql.BooleanType:
7✔
96
                return 1
7✔
97
        case sql.IntegerType:
8✔
98
                return 8
8✔
99
        case sql.Float64Type:
1✔
100
                return 8
1✔
NEW
101
        case sql.UUIDType:
×
NEW
102
                return 16
×
NEW
103
        case sql.TimestampType:
×
NEW
104
                return 8
×
105
        // VARCHAR, BLOB, JSON, ANY — variable-width
106
        default:
12✔
107
                return -1
12✔
108
        }
109
}
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