FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.19k stars 204 forks source link

Need to TRIM when using RDB$USER_PRIVILEGES #8074

Closed prrvchr closed 1 month ago

prrvchr commented 1 month ago

Hi all,

I don't know if I'm using it wrong, but I can't execute this query without the TRIM function. Is this normal?

SELECT TRIM(P.RDB$USER) FROM RDB$USER_PRIVILEGES AS P INNER JOIN SEC$USERS AS U ON TRIM(P.RDB$USER) = U.SEC$USER_NAME WHERE P.RDB$PRIVILEGE = 'M' AND P.RDB$USER_TYPE = 8 AND P.RDB$OBJECT_TYPE = 13 AND P.RDB$RELATION_NAME = ?

mrotteveel commented 1 month ago

Yes, this is normal, because the metadata tables use CHAR(63) (or (CHAR(31) in 3.0 and older) columns, which means they are padded with spaces up to the declared length.