You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/12/14 09:26:28 UTC
(iotdb) branch FixTrigger created (now 0e5fa48560e)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch FixTrigger
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at 0e5fa48560e Add Create Trigger without using uri IT
This branch includes the following new commits:
new 0e5fa48560e Add Create Trigger without using uri IT
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: Add Create Trigger without using uri IT
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch FixTrigger
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0e5fa48560e35f084d3632970a355ae6ee32b3a9
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Sat Dec 14 17:26:13 2024 +0800
Add Create Trigger without using uri IT
---
.../db/it/trigger/IoTDBTriggerManagementIT.java | 47 ++++++++++++++++++++++
.../execution/config/TreeConfigTaskVisitor.java | 6 +--
2 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/trigger/IoTDBTriggerManagementIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/trigger/IoTDBTriggerManagementIT.java
index 9a78ca427c0..b6710208556 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/trigger/IoTDBTriggerManagementIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/trigger/IoTDBTriggerManagementIT.java
@@ -286,6 +286,53 @@ public class IoTDBTriggerManagementIT {
}
}
+ @Test
+ public void testCreateTriggersNormally2() {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ Map<String, String[]> result =
+ new HashMap<String, String[]>() {
+ {
+ put(
+ STATELESS_TRIGGER_BEFORE_INSERTION_PREFIX + "a",
+ new String[] {
+ STATELESS_TRIGGER_BEFORE_INSERTION_PREFIX + "a",
+ BEFORE_INSERT,
+ STATELESS,
+ ACTIVE,
+ "root.test.stateless.a",
+ TRIGGER_FILE_TIMES_COUNTER
+ });
+ }
+ };
+
+ // create stateless triggers before insertion
+ statement.execute(
+ String.format(
+ "create stateless trigger %s before insert on root.test.stateless.a as '%s' with (\"name\"=\"%s\")",
+ STATELESS_TRIGGER_BEFORE_INSERTION_PREFIX + "a",
+ TRIGGER_FILE_TIMES_COUNTER,
+ STATELESS_TRIGGER_BEFORE_INSERTION_PREFIX + "a"));
+
+ ResultSet resultSet = statement.executeQuery("show triggers");
+ int cnt = 0;
+ while (resultSet.next()) {
+ cnt++;
+ String triggerName = resultSet.getString(ColumnHeaderConstant.TRIGGER_NAME);
+ String[] triggerInformation = result.get(triggerName);
+ assertEquals(triggerInformation[0], triggerName);
+ assertEquals(triggerInformation[1], resultSet.getString(ColumnHeaderConstant.EVENT));
+ assertEquals(triggerInformation[2], resultSet.getString(ColumnHeaderConstant.TYPE));
+ assertEquals(triggerInformation[3], resultSet.getString(ColumnHeaderConstant.STATE));
+ assertEquals(triggerInformation[4], resultSet.getString(ColumnHeaderConstant.PATH_PATTERN));
+ assertEquals(triggerInformation[5], resultSet.getString(ColumnHeaderConstant.CLASS_NAME));
+ }
+ assertEquals(cnt, result.size());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
@Test
public void testCreateAndDropMultipleTimes() {
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
index 9c0bb50e205..a1ee08d84e4 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
@@ -349,9 +349,9 @@ public class TreeConfigTaskVisitor extends StatementVisitor<IConfigTask, MPPQuer
@Override
public IConfigTask visitCreateTrigger(
CreateTriggerStatement createTriggerStatement, MPPQueryContext context) {
- if (createTriggerStatement.isUsingURI()
- && createTriggerStatement.getUriString() != null
- && isUriTrusted(createTriggerStatement.getUriString())) {
+ if (!createTriggerStatement.isUsingURI()
+ || (createTriggerStatement.getUriString() != null
+ && isUriTrusted(createTriggerStatement.getUriString()))) {
// 1. user specified uri and that uri is trusted
// 2. user doesn't specify uri
return new CreateTriggerTask(createTriggerStatement);