Masked Columns in GBase 8a: What WHERE, GROUP BY, and ORDER BY Actually See
GBase 8a, the analytical database from Chinese vendor GBASE, supports column-level data masking to keep sensitive values safe. But when a masked column is used in a WHERE filter, a GROUP BY, or an ORDER BY, does the engine work with the original value or the masked one? I ran a set of tests on a gbase cluster to find out.
Test Setup
A single-column numeric table using the default masking policy:
CREATE TABLE "testmask" ( "id" int(11) DEFAULT NULL MASKED WITH(FUNCTION='DEFAULT()') ) 5 rows of test data: 1, 2, 3, 4, 99.
Full Table Scan Without Masking Privileges
Every id comes back as 0 — the original values are hidden, exactly as expected.
gbase> select * from testmask; +------+ | id | +------+ | 0 | | 0 | | 0 | | 0 | | 0 | +------+ 5 rows in set (Elapsed: 00:00:00.02) WHERE Equality on a Masked Column
id=1 returns 1 row. The displayed value is 0, yet the user running the query has already learned that a row with id 1 exists — so the filter clearly evaluated the original value.
gbase> select * from testmask where id=1; +------+ | id | +------+ | 0 | +------+ 1 row in set (Elapsed: 00:00:00.01) GROUP BY on a Masked Column
Three rows come back with counts of 2, 1, and 2, while every projected id%3 shows 0. The grouping used the original data; only the projected column was masked.
gbase> select id%3,count(*) from testmask group by id%3; +------+----------+ | id%3 | count(*) | +------+----------+ | 0 | 2 | | 0 | 1 | | 0 | 2 | +------+----------+ 3 rows in set (Elapsed: 00:00:00.09) Migrating a Masked Column with UPDATE
Add a column and copy id into it — both id and id2 read 0. The table definition shows id2 has no masking attribute, meaning the database physically stored 0: masking happened before the write, not at read time.
gbase> alter table testmask add column id2 int; Query OK, 5 rows affected (Elapsed: 00:00:00.15) gbase> update testmask set id2=id; Query OK, 5 rows affected (Elapsed: 00:00:00.07) gbase> select * from testmask; +------+------+ | id | id2 | +------+------+ | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | +------+------+ 5 rows in set (Elapsed: 00:00:00.01) CREATE TABLE "testmask" ( "id" int(11) DEFAULT NULL MASKED WITH(FUNCTION='DEFAULT()'), "id2" int(11) DEFAULT NULL ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' Dumping a Masked Column with INSERT ... SELECT
create table testmask2 as select * from testmask produces the same masked all-zero values — the mask is baked into the copied data.
ORDER BY on a Masked Column
Sorting by id desc returns rowids 4, 3, 2, 1, 0, matching the descending order of the original values 99, 4, 3, 2, 1. The sort used original values too.
gbase> select rowid,t.* from testmask t order by id desc; +-------+------+------+ | rowid | id | id2 | +-------+------+------+ | 4 | 0 | 0 | | 3 | 0 | 0 | | 2 | 0 | 0 | | 1 | 0 | 0 | | 0 | 0 | 0 | +-------+------+------+ 5 rows in set (Elapsed: 00:00:00.03) What This Means
- A masked column returned as a projection to the application is masked.
- A masked column copied as a projection into another column or another table is masked.
- A masked column used as a non-projection column — WHERE filtering, GROUP BY, ORDER BY — is not masked at all; the original value participates in the operation.
Oracle's Data Redaction Policies behave the same way: redaction happens only when data is returned to the application. The practical takeaway is that masking is not a substitute for access control. By probing WHERE conditions repeatedly, a user can still infer that specific original values exist, even though every value they see is 0. If you rely on masking in gbase, combine it with proper privileges rather than treating the masked output as a security boundary.