Skip to content

SQL/JSON expression generation #55

@alvherre

Description

@alvherre

Hello

There's been some work on adding SQL/JSON features to Postgres, and it would be great to have sqlsmith run through them and see how many problems can be found. However, those features have a bespoke syntax, so I'm afraid the current sqlsmith is not covering all of the new code.

Would it be possible to add support for those features so that we can harden the code more?

Some examples (from the src/test/regress/sql/sqljson.sql file)

SELECT JSON_OBJECT(
    'a': '123',
    1.23 value 123,
    'c': json '[ 1,true,{ } ]',
    'd': jsonb '{ "x" : 123.45 }'
    RETURNING jsonb
);
SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea) FORMAT JSON);
SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, 4: NULL, '5': 'a' ABSENT ON NULL WITH UNIQUE RETURNING jsonb);
SELECT JSON_ARRAYAGG(foo ORDER BY bar RETURNING jsonb) FILTER (WHERE bar > 2) FROM
    (VALUES (NULL), (3), (1), (NULL), (NULL), (5), (2), (4), (NULL)) foo(bar);
SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) OVER (PARTITION BY i % 2)
FROM generate_series(1,5) i;

Upcoming patches have extra stuff, such as the IS JSON VALUE expression and more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions