From: | Денис Романенко <deromanenko(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Data loss when '"json_populate_recorset" with long column name |
Date: | 2021-09-07 03:27:04 |
Message-ID: | CALSd-cppwDQ5+AmvrZ7a+XKQBCE9amS1uRK3X60=q1iL7x0SaQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
If we create a column name longer than 64 bytes, it will be truncated in
PostgreSQL to max (NAMEDATALEN) length.
For example: "
VeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongName"
will be truncated in database to "
VeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongNameVer"
But in the codebase we could work with full column name - SQL functions
like INSERT/UPDATE work with long names without problem, automatically
searches for suitable column (thank you for it).
But if we try to update it with "json_populate_recordset" using full name,
it will not just ignore column with long name - data in that record will be
nulled.
How to reproduce:
1. create table wow("
VeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongName"
text);
2. select * from
json_populate_recordset(null::wow,'[{"VeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongName":
"haha"}]');
3. "VeryLongNameVeryLongNameVeryLongNameVeryLongNameVeryLongNameVer"
becomes null.
P.S. Why do I need columns with more than 64 bytes length - because I use
non-Latin characters in column and table names, so In fact I have only 32
chars because of Unicode. (PostgreSQL: NAMEDATALEN increase because of
non-latin languages
<https://www.postgresql.org/message-id/CALSd-crdmj9PGdvdioU%3Da5W7P%3DTgNmEB2QP9wiF6DTUbBuMXrQ%40mail.gmail.com>
)
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2021-09-07 03:30:00 | Re: Allow escape in application_name (was: [postgres_fdw] add local pid to fallback_application_name) |
Previous Message | Amit Kapila | 2021-09-07 03:08:47 | Re: [BUG] Failed Assertion in ReorderBufferChangeMemoryUpdate() |