Skip to content

Input of aclitem - #275

Merged
tamnd merged 1 commit into
mainfrom
aclin
Oct 13, 2026
Merged

tamnd merged 1 commit into
mainfrom
aclin

Conversation

@tamnd

@tamnd tamnd commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

rupg gave 0A000 for the input of aclitem, so a literal such as 'postgres=r/postgres'::aclitem failed. This change ports the input function of aclitem from acl.c, and the functions makeaclitem, aclcontains, aclitemeq, hash_aclitem, hash_aclitem_extended, aclinsert and aclremove. The results come from PostgreSQL 19.

Changes

  • aclitem_in reads an item as aclparse does. A role name can have double quotes, and "" in quotes is a quote. The key word group or user can come before the grantee. An empty grantee is PUBLIC, and a * after a privilege is its grant option. A name of 64 bytes or more gives 42622, a role that does not exist gives 42704, and a bad item gives 22P02 with the message and the hint of PostgreSQL. All of these are soft errors, so pg_input_is_valid and pg_input_error_info report them.
  • An item with no grantor has the bootstrap superuser as its grantor, and the input sends the warning 0L000 "defaulting grantor to user ID 10", as PostgreSQL does. A function can now send a warning through the new method warn of rupg_func::Session. The reader of a statement keeps the warnings, and the session sends them before the result or the error of the statement.
  • The analyzer reads a literal through the new method input_at of Env, so that a warning of the input function points at the literal. This applies to a simple query, to Parse and to PREPARE.
  • aclcontains and the operator @> check that the array has one dimension and no null items, then look for an item with the same grantee and grantor and all the privileges and grant options of the item. aclexplode reads its items with the same parser, so an item with a role that does not exist gives the OID of the role.
  • makeaclitem reads the names of the privileges of all kinds of objects, which include TEMP, TEMPORARY and ALTER SYSTEM.
  • hash_aclitem gives the sum of the privileges, the grantee and the grantor in 32 bits. hash_aclitem_extended gives the same sum for the seed 0. Another seed gives 0A000, because the engine does not have the hash of hashfn.c yet.
  • aclinsert and aclremove give 0A000 with the message of PostgreSQL.
  • The binary output and input of aclitem give 42883 "no binary output function available for type aclitem", as PostgreSQL does for a type that has no send or receive function.
  • PostgreSQL sends CopyOutResponse before it runs the query of COPY ... TO STDOUT. rupg now sends CopyOutResponse before an error of the run too, in a simple query and in Execute.
  • The output of a role name now uses double quotes when the name has a character that is not an ASCII letter, an ASCII digit or _, as putid does.

Tests

  • acl in rupg-session runs 73 statements with the output of PostgreSQL 19 for the same script in a new database. It has the text forms, the errors, the warnings in a simple query and in Parse, the soft errors, makeaclitem, aclcontains, aclexplode, the hash functions, the arrays, the text forms of COPY and the error of the binary form.
  • fmt, clippy, the workspace tests, the xtask checks and cargo doc pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 13, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. gate/G1 G1: 7 clients connect and show the schema (L1, L2). area/types Types, type I/O, casts and collations. labels Oct 13, 2026
@tamnd tamnd self-assigned this Oct 13, 2026
@tamnd
tamnd merged commit f2a267a into main Oct 13, 2026
5 checks passed
@tamnd
tamnd deleted the aclin branch October 13, 2026 07:50
@tamnd tamnd mentioned this pull request Oct 13, 2026
15 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/types Types, type I/O, casts and collations. gate/G1 G1: 7 clients connect and show the schema (L1, L2). kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant