fix: Make recursive view parsing work with XMLTABLE + DEFAULT
This commit is contained in:
committed by
Steve Chavez
parent
eedfe957b5
commit
7db4a75146
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- #2020, Execute deferred constraint triggers when using `Prefer: tx=rollback` - @wolfgangwalther
|
- #2020, Execute deferred constraint triggers when using `Prefer: tx=rollback` - @wolfgangwalther
|
||||||
- #2058, Return 204 No Content without Content-Type for PUT - @wolfgangwalther
|
- #2058, Return 204 No Content without Content-Type for PUT - @wolfgangwalther
|
||||||
- #2077, Fix `is` not working with upper or mixed case values like `NULL, TrUe, FaLsE` - @steve-chavez
|
- #2077, Fix `is` not working with upper or mixed case values like `NULL, TrUe, FaLsE` - @steve-chavez
|
||||||
|
- #2024, Fix schema cache loading when views with XMLTABLE and DEFAULT are present - @wolfgangwalther
|
||||||
|
|
||||||
## [9.0.0] - 2021-11-25
|
## [9.0.0] - 2021-11-25
|
||||||
|
|
||||||
|
|||||||
@@ -792,7 +792,6 @@ pfkSourceColumns cols =
|
|||||||
replace(
|
replace(
|
||||||
replace(
|
replace(
|
||||||
replace(
|
replace(
|
||||||
replace(
|
|
||||||
regexp_replace(
|
regexp_replace(
|
||||||
replace(
|
replace(
|
||||||
replace(
|
replace(
|
||||||
@@ -803,6 +802,7 @@ pfkSourceColumns cols =
|
|||||||
replace(
|
replace(
|
||||||
replace(
|
replace(
|
||||||
replace(
|
replace(
|
||||||
|
replace(
|
||||||
replace(
|
replace(
|
||||||
view_definition::text,
|
view_definition::text,
|
||||||
-- This conversion to json is heavily optimized for performance.
|
-- This conversion to json is heavily optimized for performance.
|
||||||
@@ -814,9 +814,15 @@ pfkSourceColumns cols =
|
|||||||
-- -----------------------------------------------
|
-- -----------------------------------------------
|
||||||
-- pattern | replacement | flags
|
-- pattern | replacement | flags
|
||||||
-- -----------------------------------------------
|
-- -----------------------------------------------
|
||||||
|
-- `<>` in pg_node_tree is the same as `null` in JSON, but due to very poor performance of json_typeof
|
||||||
|
-- we need to make this an empty array here to prevent json_array_elements from throwing an error
|
||||||
|
-- when the targetList is null.
|
||||||
|
-- We'll need to put it first, to make the node protection below work for node lists that start with
|
||||||
|
-- null: `(<> ...`, too. This is the case for coldefexprs, when the first column does not have a default value.
|
||||||
|
'<>' , '()'
|
||||||
-- `,` is not part of the pg_node_tree format, but used in the regex.
|
-- `,` is not part of the pg_node_tree format, but used in the regex.
|
||||||
-- This removes all `,` that might be part of column names.
|
-- This removes all `,` that might be part of column names.
|
||||||
',' , ''
|
), ',' , ''
|
||||||
-- The same applies for `{` and `}`, although those are used a lot in pg_node_tree.
|
-- The same applies for `{` and `}`, although those are used a lot in pg_node_tree.
|
||||||
-- We remove the escaped ones, which might be part of column names again.
|
-- We remove the escaped ones, which might be part of column names again.
|
||||||
), E'\\{' , ''
|
), E'\\{' , ''
|
||||||
@@ -851,10 +857,6 @@ pfkSourceColumns cols =
|
|||||||
), ')' , ']'
|
), ')' , ']'
|
||||||
-- pg_node_tree has ` ` between list items, but JSON uses `,`
|
-- pg_node_tree has ` ` between list items, but JSON uses `,`
|
||||||
), ' ' , ','
|
), ' ' , ','
|
||||||
-- `<>` in pg_node_tree is the same as `null` in JSON, but due to very poor performance of json_typeof
|
|
||||||
-- we need to make this an empty array here to prevent json_array_elements from throwing an error
|
|
||||||
-- when the targetList is null.
|
|
||||||
), '<>' , '[]'
|
|
||||||
)::json as view_definition
|
)::json as view_definition
|
||||||
from views
|
from views
|
||||||
),
|
),
|
||||||
|
|||||||
Vendored
+18
@@ -2462,3 +2462,21 @@ BEGIN
|
|||||||
|
|
||||||
INSERT INTO deferrable_unique_constraint VALUES (1), (1);
|
INSERT INTO deferrable_unique_constraint VALUES (1), (1);
|
||||||
END$$;
|
END$$;
|
||||||
|
|
||||||
|
-- This view is not used in any requests but just parsed by the pfkSourceColumns query.
|
||||||
|
-- XMLTABLE is only supported from PG 10 on
|
||||||
|
DO $do$
|
||||||
|
BEGIN
|
||||||
|
IF current_setting('server_version_num')::INT >= 100000 THEN
|
||||||
|
CREATE VIEW test.xml AS
|
||||||
|
SELECT *
|
||||||
|
FROM (SELECT ''::xml AS data) _,
|
||||||
|
XMLTABLE(
|
||||||
|
''
|
||||||
|
PASSING data
|
||||||
|
COLUMNS id int PATH '@id',
|
||||||
|
premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified'
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$do$;
|
||||||
|
|||||||
Reference in New Issue
Block a user