| От | Matheus Alcantara |
|---|---|
| Тема | Show expression of virtual columns in error messages |
| Дата | |
| Msg-id | DG5DV8SED62G.2WFJB46D7WIT8@gmail.com обсуждение исходный текст |
| Ответы |
Re: Show expression of virtual columns in error messages
|
| Список | pgsql-hackers |
Hi, When a constraint violation occurs on a table with virtual generated columns, the "Failing row contains" error message currently displays the literal string "virtual" as a placeholder: CREATE TABLE t (a int, b int, c int GENERATED ALWAYS AS (a * 2) VIRTUAL CHECK (c < 10)); INSERT INTO t VALUES (5, 10); ERROR: new row for relation "t" violates check constraint "t_c_check" DETAIL: Failing row contains (5, 10, virtual). This isn't very helpful for debugging, especially when the user needs to understand why the check constraint failed or if multiple virtual generated columns are involved on the original statement. The attached patch changes this behavior to show the virtual column expression instead: ERROR: new row for relation "t" violates check constraint "t_c_check" DETAIL: Failing row contains (5, 10, a * 2). An alternative approach would be to compute and display the actual value of the virtual column (e.g., "10" instead of "a * 2"). However, I chose to show the expression because: 1. It's simpler to implement (no need to evaluate the expression) 2. It shows the user *how* the value is computed, which may be more useful for understanding why a constraint failed 3. It avoids potential issues with expression evaluation in error paths Thoughts? -- Matheus Alcantara EDB: https://www.enterprisedb.com
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера