diff --git a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementVisitor.java b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementVisitor.java index 9ae6e809cc31c..b41878c289fa2 100644 --- a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementVisitor.java +++ b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementVisitor.java @@ -708,8 +708,10 @@ public ASTNode visitInsert(final InsertContext ctx) { @Override public ASTNode visitOptOnConflict(final OptOnConflictContext ctx) { - SetClauseListContext setClauseListContext = ctx.setClauseList(); - Collection assignments = ((SetAssignmentSegment) visit(setClauseListContext)).getAssignments(); + Collection assignments = new LinkedList<>(); + if (null != ctx.setClauseList()) { + assignments = ((SetAssignmentSegment) visit(ctx.setClauseList())).getAssignments(); + } return new OnDuplicateKeyColumnsSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments); } diff --git a/test/it/parser/src/main/resources/case/dml/insert.xml b/test/it/parser/src/main/resources/case/dml/insert.xml index 08615512c2f80..05a351e7718b5 100644 --- a/test/it/parser/src/main/resources/case/dml/insert.xml +++ b/test/it/parser/src/main/resources/case/dml/insert.xml @@ -4140,4 +4140,20 @@ + + + + + + + + + + + + + + + + diff --git a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml index 962a12e318946..d5ad8384ec4e2 100644 --- a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml +++ b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml @@ -149,4 +149,5 @@ +