From 4f926f103ff7232b30bb4f3d4a45db0ad7fe01c5 Mon Sep 17 00:00:00 2001 From: Eric Mustin Date: Mon, 6 Jan 2025 10:51:05 -0500 Subject: [PATCH] fix: Update instrumentation pg to support merge statements (#1317) * fix: support merge statement in pg versions 15+ * chore: fix json formatting for pg fixtures * chore: use aliases in pg fixtures table for merge statement --- .../pg/lib/opentelemetry/instrumentation/pg/constants.rb | 3 +-- instrumentation/pg/test/fixtures/sql_table_name.json | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb index 73d9c8710..d248cbdb0 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb @@ -40,10 +40,10 @@ module Constants LISTEN LOAD LOCK + MERGE MOVE NOTIFY PREPARE - PREPARE REASSIGN REFRESH REINDEX @@ -54,7 +54,6 @@ module Constants SAVEPOINT SECURITY SELECT - SELECT SET SHOW START diff --git a/instrumentation/pg/test/fixtures/sql_table_name.json b/instrumentation/pg/test/fixtures/sql_table_name.json index 7cf96681f..852d1dcea 100644 --- a/instrumentation/pg/test/fixtures/sql_table_name.json +++ b/instrumentation/pg/test/fixtures/sql_table_name.json @@ -54,5 +54,9 @@ { "name": "table_name_with_double_quotes", "sql": "SELECT columns FROM \"test_table\"" + }, + { + "name": "merge", + "sql": "MERGE INTO test_table AS t USING other_table AS o ON (o.id = t.id) WHEN MATCHED THEN UPDATE SET x = t.x + 1 WHEN NOT MATCHED THEN INSERT (id, x, status) VALUES (o.id, o.x, o.status)" } ]