Re: pgsql: Add more SQL/JSON constructor functions
От | jian he |
---|---|
Тема | Re: pgsql: Add more SQL/JSON constructor functions |
Дата | |
Msg-id | CACJufxFu6bBbeVOqjbu2kBjNeOMLDZ6oYnqkyEd3Ev+p8C5Ohw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: pgsql: Add more SQL/JSON constructor functions (jian he <jian.universality@gmail.com>) |
Список | pgsql-hackers |
While reviewing the patch, I found some inconsistency on json_table EXISTS. --tested based on your patch and master. src4=# SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a jsonb EXISTS PATH '$')); ERROR: cannot cast behavior expression of type boolean to jsonb src4=# SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a jsonb EXISTS PATH '$' error on error)); a ------ true (1 row) Why explicitly "error on error" not report error while not explicitly mentioning it yields an error? "(a jsonb EXISTS PATH '$' error on error)" returns jsonb 'true' imply that no errors happened. so "(a jsonb EXISTS PATH '$')" should not have any errors. but boolean cannot cast to jsonb so for JSON_TABLE, we should reject COLUMNS (a jsonb EXISTS PATH '$' error on error )); COLUMNS (a jsonb EXISTS PATH '$' unknown on error )); at an earlier stage. because json_populate_type will use literal 'true'/'false' cast to jsonb, which will not fail. but JsonPathExists returns are *not* quoted true/false. so rejecting it earlier is better than handling it at ExecEvalJsonExprPath. attached patch trying to solve the problem, changes applied based on your 0001, 0002. after apply attached patch: create domain djsonb as jsonb check(value = 'true'); SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a djsonb EXISTS PATH '$' error on error)); ERROR: cannot cast type boolean to djsonb SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a djsonb EXISTS PATH '$' unknown on error)); ERROR: cannot cast type boolean to djsonb SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a jsonb EXISTS PATH '$')); ERROR: cannot cast type boolean to jsonb i found out a typo in src/test/regress/expected/sqljson_queryfuncs.out, src/test/regress/sql/sqljson_queryfuncs.sql "fixed-legth" should be "fixed-length"
Вложения
В списке pgsql-hackers по дате отправления: