cockroachdb / cockroachdb/docs

Feedback: Row-Level Security (RLS) Overview - misc. feedback

Open
#19,607 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
212
Forks
476
Avg merge
40m
Merged PRs (30d)
3

Description

Page: https://cockroachlabs.com/docs/v25.2/row-level-security.html

## What is the reason for your feedback?

[ ] Missing the information I need

[ ] Too complicated

[ ] Out of date

[ ] Something is broken

[X] Other

## Additional details

This is great doc overall! Here are a few points of feedback:

Says:

> Define the hr_department role and employees table, add some data, and grant basic table access:

But more than just the hr_department role is defined so the statement does not match the example code

Example says:

> -- Assume roles 'hr_department' and potentially others exist.

This comment is confusing and does not add value

Example says:

> CREATE TABLE employees (
> id SERIAL PRIMARY KEY,

SERIAL is an anti-pattern; better to use UUID

Ditto for

> CREATE TABLE IF NOT EXISTS invoices (
> invoice_id SERIAL PRIMARY KEY,

Says:

> In this example, we use the CURRENT_USER special form of the function with the same name.

But both this example and the example above use CURRENT_USER (so the above comment should be moved up and reference both examples, not just "this example")

Says:

> **Define how the application sets the tenant ID for the session**
> Each application will need to set the tenant context for the session. In this example, you will use the application_name session variable to pass in a tenant ID that will later be extracted from the variable.

However, this approach increases the cardinality of application names, which can break CockroachDB internal statement statistics. Please use a different approach that does not involve encoding the tenant ID into the application name.

Says:

> **Warning:**
> For multi-tenancy to work correctly, this setting must be reliably managed by the application layer and passed in the connection string.

But the example does not show it being passed in the connection string; the example shows it being set via a session variable.
The comment would be improved if it says that the application name can be specified using either the connection string or the application_name session variable

Jira issue: DOC-13672

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Row-Level Security Overview at https://cockroachlabs.com/docs/v25.2/row-level-security.html and review each cited SQL example alongside its surrounding prose. Done means the role and table descriptions match the code, CURRENT_USER guidance covers both examples, SERIAL usage is addressed, and the tenant-ID guidance no longer conflicts with the shown session-variable approach or statement-statistics concerns.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.