Re: Fixes a trivial bug in dumped parse/query/plan trees
От | Stepan Neretin |
---|---|
Тема | Re: Fixes a trivial bug in dumped parse/query/plan trees |
Дата | |
Msg-id | CA+Yyo5SADqvKzD-5ppYNFE+DMC5fFxVo4=Y9FBDQqkJFrEUhMA@mail.gmail.com обсуждение исходный текст |
Ответ на | Fixes a trivial bug in dumped parse/query/plan trees (Chao Li <li.evan.chao@gmail.com>) |
Ответы |
Re: Fixes a trivial bug in dumped parse/query/plan trees
|
Список | pgsql-hackers |
On Mon, Aug 25, 2025 at 7:55 AM Chao Li <li.evan.chao@gmail.com> wrote:
Hi Hackers,
This patch fixes a trivial bug where an extra whitespace was added
when dumping an array, for example:
```
:sort.numCols 2
:sort.sortColIdx ( 1 4)
:sort.sortOperators ( 97 1754)
:sort.collations ( 0 0)
:sort.nullsFirst ( false false)
```
The unnecessary whitespace is now removed.Regard regards,
Hi Chao,
I was able to reproduce the problem using a small test:
```sql
SET debug_print_parse = on;
CREATE TABLE test_sort_example (
id SERIAL PRIMARY KEY,
col1 INT,
col2 TEXT,
col3 TEXT
);
INSERT INTO test_sort_example (col1, col2, col3) VALUES
(1, 'apple', 'zebra'),
(2, 'banana', 'yak'),
(3, 'cherry', 'xylophone'),
(4, 'date', 'wolf');
SELECT * FROM test_sort_example
ORDER BY col2 ASC, col3 ASC;
```
The extra whitespace in the array dump (e.g.,
```
:sort.numCols 2
:sort.sortColIdx ( 1 4)
:sort.sortOperators ( 97 1754)
:sort.collations ( 0 0)
:sort.nullsFirst ( false false)
```
) was indeed present before the patch.
After applying your patch, the issue is fixed, and the array is now dumped correctly without extra spaces. The patch looks good to me.
Regarding testing: for this case, a Perl test might actually be more suitable than SQL tests, because OIDs can change between runs and Perl tests allow for better control and normalization of such values.
Best regards,
Stepan Neretin
I was able to reproduce the problem using a small test:
```sql
SET debug_print_parse = on;
CREATE TABLE test_sort_example (
id SERIAL PRIMARY KEY,
col1 INT,
col2 TEXT,
col3 TEXT
);
INSERT INTO test_sort_example (col1, col2, col3) VALUES
(1, 'apple', 'zebra'),
(2, 'banana', 'yak'),
(3, 'cherry', 'xylophone'),
(4, 'date', 'wolf');
SELECT * FROM test_sort_example
ORDER BY col2 ASC, col3 ASC;
```
The extra whitespace in the array dump (e.g.,
```
:sort.numCols 2
:sort.sortColIdx ( 1 4)
:sort.sortOperators ( 97 1754)
:sort.collations ( 0 0)
:sort.nullsFirst ( false false)
```
) was indeed present before the patch.
After applying your patch, the issue is fixed, and the array is now dumped correctly without extra spaces. The patch looks good to me.
Regarding testing: for this case, a Perl test might actually be more suitable than SQL tests, because OIDs can change between runs and Perl tests allow for better control and normalization of such values.
Best regards,
Stepan Neretin
В списке pgsql-hackers по дате отправления: