jrgemignani opened a new pull request, #1989:
URL: https://github.com/apache/age/pull/1989

   Fixed the issue with creating a label name close to `MAX_LABEL_NAME_LEN`. 
Well, sort of.
   
   The issue here is that a label name is the name of a relation in PostgreSQL. 
While the relation name is a `char *` it is basically converted to a PG type 
`Name` when it is used to create a relation. This conversion is a silent 
truncation, there are no warnings or error messages. The `Name` type is defined 
as follows -
   
   ```
       /*
        * Representation of a Name: effectively just a C string, but 
null-padded to
        * exactly NAMEDATALEN bytes.  The use of a struct is historical. 
        */ 
       typedef struct nameData
       {
           char data[NAMEDATALEN]; 
       } NameData;
       typedef NameData *Name;
   ```
   
   This effectively gives us a max label name length of `NAMEDATALEN - 1`.
   
   ```
       /*
        * Maximum length for identifiers (e.g. table names, column names,
        * function names).  Names actually are limited to one fewer byte than 
this, 
        * because the length must include a trailing zero byte.
        * 
        * This should be at least as much as NAMEDATALEN of the database the 
        * applications run against. 
        */ 
       #define NAMEDATALEN 64
   ```
   
   Since there isn't a way to get around this, the code was modified to reflect 
the usage of `NAMEDATALEN` for the length of label names. This required 
modifying the input parameters to be cstrings, which allows us to tell when 
`NAMEDATALEN` has been exceeded.
   
   Additionally, the function `is_valid_label` was renamed to 
`is_valid_label_name` for consistency.
   
   Regression tests were updated and added.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to