Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MySQL] json_valid() function does not exist in PG/YB #833

Open
shubham-yb opened this issue May 8, 2023 · 0 comments
Open

[MySQL] json_valid() function does not exist in PG/YB #833

shubham-yb opened this issue May 8, 2023 · 0 comments
Labels
dep-issue Issues with dependencies documentation Improvements or additions to documentation

Comments

@shubham-yb
Copy link
Contributor

shubham-yb commented May 8, 2023

MySQL has a function json_valid() which returns 0 or 1 to indicate whether a value is valid JSON.
We do not have an alternative function to do this in PG/YB.

Workaround:

Create the function manually on the target.:

create or replace function json_valid(p_json text)
  returns boolean
as
$$
begin
  return (p_json::json is not null);
exception 
  when others then
     return false;  
end;
$$
language plpgsql
immutable;
@github-actions github-actions bot added the triage Needs to be triaged label May 8, 2023
@shubham-yb shubham-yb added documentation Improvements or additions to documentation dep-issue Issues with dependencies and removed triage Needs to be triaged labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dep-issue Issues with dependencies documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant