Re: sql/json remaining issue
От | jian he |
---|---|
Тема | Re: sql/json remaining issue |
Дата | |
Msg-id | CACJufxGOerH1QJknm1noh-Kz5FqU4p7QfeZSeVT2tN_4SLXYNg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: sql/json remaining issue (jian he <jian.universality@gmail.com>) |
Список | pgsql-hackers |
hi. https://wiki.postgresql.org/wiki/PostgreSQL_17_Open_Items#Open_Issues issue: Problems with deparsed SQL/JSON query function original the bug report link: https://postgr.es/m/CACJufxEqhqsfrg_p7EMyo5zak3d767iFDL8vz_4%3DZBHpOtrghw@mail.gmail.com forgive me for putting it in the new email thread. I made the following change, added several tests on it. --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -4636,10 +4636,10 @@ transformJsonBehavior(ParseState *pstate, JsonBehavior *behavior, { expr = transformExprRecurse(pstate, behavior->expr); if (!IsA(expr, Const) && !IsA(expr, FuncExpr) && - !IsA(expr, OpExpr)) + !IsA(expr, OpExpr) && !IsA(expr, CoerceViaIO) && !IsA(expr, CoerceToDomain)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("can only specify a constant, non-aggregate function, or operator expression for DEFAULT"), + errmsg("can only specify a constant, non-aggregate function, or operator expression or cast expression for DEFAULT"), parser_errposition(pstate, exprLocation(expr)))); if (contain_var_clause(expr)) ereport(ERROR, these two expression node also looks like Const: CoerceViaIO: "foo1"'::jsonb::text CoerceToDomain: 'foo'::jsonb_test_domain we need to deal with these two, otherwise we cannot use domain type in DEFAULT expression. also the following should not fail: SELECT JSON_VALUE(jsonb '{"d1": "foo"}', '$.a2' returning text DEFAULT '"foo1"'::text::json::text ON ERROR); we have `if (contain_var_clause(expr))` further check it, so it should be fine?
Вложения
В списке pgsql-hackers по дате отправления: