Skip to content

Conversation

@mattpetersen
Copy link
Contributor

@mattpetersen mattpetersen commented Jan 3, 2026

Summary

Support [ENABLE / DISABLE / FORCE / NO FORCE] ROW LEVEL SECURITY, an ALTER TABLE command Postgres added in release 9.5.

Adds two new keywords:

  • keyword_enable
  • keyword_disable

Adds one new branch to the alter_table grammar rule.

Current behavior:

tree-sitter generate && echo 'ALTER TABLE my_table ENABLE ROW LEVEL SECURITY;' | tree-sitter parse
(program [0, 0] - [1, 0]
  (statement [0, 0] - [0, 31]
    (alter_table [0, 0] - [0, 31]
      (keyword_alter [0, 0] - [0, 5])
      (keyword_table [0, 6] - [0, 11])
      (object_reference [0, 12] - [0, 20]
        name: (identifier [0, 12] - [0, 20]))
      (add_column [0, 21] - [0, 31]
        (column_definition [0, 21] - [0, 31]
          name: (identifier [0, 21] - [0, 27])
          custom_type: (object_reference [0, 28] - [0, 31]
            name: (identifier [0, 28] - [0, 31]))))))
  (ERROR [0, 32] - [0, 46]
    (keyword_security [0, 38] - [0, 46])))

Behavior after this change:

(program [0, 0] - [1, 0]
  (statement [0, 0] - [0, 46]
    (alter_table [0, 0] - [0, 46]
      (keyword_alter [0, 0] - [0, 5])
      (keyword_table [0, 6] - [0, 11])
      (object_reference [0, 12] - [0, 20]
        name: (identifier [0, 12] - [0, 20]))
      (keyword_enable [0, 21] - [0, 27])
      (keyword_row [0, 28] - [0, 31])
      (keyword_level [0, 32] - [0, 37])
      (keyword_security [0, 38] - [0, 46]))))

Test this change:

git fetch && git switch mp/row-level-security

tree-sitter generate && tree-sitter test

Issue link:

#345

@mattpetersen
Copy link
Contributor Author

I'll fix the CI issues later tonight. Thanks for running!

@dmfay
Copy link
Collaborator

dmfay commented Jan 3, 2026

Sounds good, thanks for adding these! Everything else looks good to me.

Support [ENABLE / DISABLE / FORCE / NO FORCE] ROW LEVEL SECURITY

DerekStride#345
@mattpetersen mattpetersen force-pushed the mp/row-level-security branch from 87213dd to d73bd9c Compare January 3, 2026 21:04
@dmfay dmfay merged commit 7d93f59 into DerekStride:main Jan 3, 2026
4 checks passed
@mattpetersen mattpetersen deleted the mp/row-level-security branch January 4, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants