mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Fix pg_stat_statements for MERGE
We weren't jumbling the merge action list, so wildly different commands would be considered to use the same query ID. Add that, mention it in the docs, and some test lines. Backpatch to 15. Author: Tatsu <bt22nakamorit@oss.nttdata.com> Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Discussion: https://postgr.es/m/d87e391694db75a038abc3b2597828e8@oss.nttdata.com
This commit is contained in:
@ -100,6 +100,28 @@ SELECT * FROM test ORDER BY a;
|
||||
-- SELECT with IN clause
|
||||
SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
|
||||
|
||||
-- MERGE
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN MATCHED THEN UPDATE SET b = st.b || st.a::text;
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN MATCHED THEN UPDATE SET b = test.b || st.a::text;
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN MATCHED AND length(st.b) > 1 THEN UPDATE SET b = test.b || st.a::text;
|
||||
MERGE INTO test USING test st ON (st.a = test.a)
|
||||
WHEN NOT MATCHED THEN INSERT (a, b) VALUES (0, NULL);
|
||||
MERGE INTO test USING test st ON (st.a = test.a)
|
||||
WHEN NOT MATCHED THEN INSERT VALUES (0, NULL); -- same as above
|
||||
MERGE INTO test USING test st ON (st.a = test.a)
|
||||
WHEN NOT MATCHED THEN INSERT (b, a) VALUES (NULL, 0);
|
||||
MERGE INTO test USING test st ON (st.a = test.a)
|
||||
WHEN NOT MATCHED THEN INSERT (a) VALUES (0);
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN MATCHED THEN DELETE;
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN MATCHED THEN DO NOTHING;
|
||||
MERGE INTO test USING test st ON (st.a = test.a AND st.a >= 4)
|
||||
WHEN NOT MATCHED THEN DO NOTHING;
|
||||
|
||||
SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
|
Reference in New Issue
Block a user