diff options
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 7 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_gram.y | 8 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_unreserved_kwlist.h | 1 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/plpgsql.h | 2 |
4 files changed, 15 insertions, 3 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 915139378e..00328fddcf 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -4194,7 +4194,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, /* * On the first call for this statement generate the plan, and detect - * whether the statement is INSERT/UPDATE/DELETE + * whether the statement is INSERT/UPDATE/DELETE/MERGE */ if (expr->plan == NULL) exec_prepare_plan(estate, expr, CURSOR_OPT_PARALLEL_OK); @@ -4216,7 +4216,8 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, */ if (plansource->commandTag == CMDTAG_INSERT || plansource->commandTag == CMDTAG_UPDATE || - plansource->commandTag == CMDTAG_DELETE) + plansource->commandTag == CMDTAG_DELETE || + plansource->commandTag == CMDTAG_MERGE) { stmt->mod_stmt = true; break; @@ -4276,6 +4277,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, case SPI_OK_INSERT_RETURNING: case SPI_OK_UPDATE_RETURNING: case SPI_OK_DELETE_RETURNING: + case SPI_OK_MERGE: Assert(stmt->mod_stmt); exec_set_found(estate, (SPI_processed != 0)); break; @@ -4457,6 +4459,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, case SPI_OK_INSERT_RETURNING: case SPI_OK_UPDATE_RETURNING: case SPI_OK_DELETE_RETURNING: + case SPI_OK_MERGE: case SPI_OK_UTILITY: case SPI_OK_REWRITTEN: break; diff --git a/src/pl/plpgsql/src/pl_gram.y b/src/pl/plpgsql/src/pl_gram.y index 954c2df331..11e86c1609 100644 --- a/src/pl/plpgsql/src/pl_gram.y +++ b/src/pl/plpgsql/src/pl_gram.y @@ -306,6 +306,7 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt); %token <keyword> K_LAST %token <keyword> K_LOG %token <keyword> K_LOOP +%token <keyword> K_MERGE %token <keyword> K_MESSAGE %token <keyword> K_MESSAGE_TEXT %token <keyword> K_MOVE @@ -2000,6 +2001,10 @@ stmt_execsql : K_IMPORT { $$ = make_execsql_stmt(K_INSERT, @1); } + | K_MERGE + { + $$ = make_execsql_stmt(K_MERGE, @1); + } | T_WORD { int tok; @@ -2537,6 +2542,7 @@ unreserved_keyword : | K_IS | K_LAST | K_LOG + | K_MERGE | K_MESSAGE | K_MESSAGE_TEXT | K_MOVE @@ -3000,6 +3006,8 @@ make_execsql_stmt(int firsttoken, int location) { if (prev_tok == K_INSERT) continue; /* INSERT INTO is not an INTO-target */ + if (prev_tok == K_MERGE) + continue; /* MERGE INTO is not an INTO-target */ if (firsttoken == K_IMPORT) continue; /* IMPORT ... INTO is not an INTO-target */ if (have_into) diff --git a/src/pl/plpgsql/src/pl_unreserved_kwlist.h b/src/pl/plpgsql/src/pl_unreserved_kwlist.h index 1c68420331..ee2be1b212 100644 --- a/src/pl/plpgsql/src/pl_unreserved_kwlist.h +++ b/src/pl/plpgsql/src/pl_unreserved_kwlist.h @@ -70,6 +70,7 @@ PG_KEYWORD("insert", K_INSERT) PG_KEYWORD("is", K_IS) PG_KEYWORD("last", K_LAST) PG_KEYWORD("log", K_LOG) +PG_KEYWORD("merge", K_MERGE) PG_KEYWORD("message", K_MESSAGE) PG_KEYWORD("message_text", K_MESSAGE_TEXT) PG_KEYWORD("move", K_MOVE) diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 18a4f6c7d3..813c32c70f 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -893,7 +893,7 @@ typedef struct PLpgSQL_stmt_execsql int lineno; unsigned int stmtid; PLpgSQL_expr *sqlstmt; - bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? */ + bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE/MERGE? */ bool mod_stmt_set; /* is mod_stmt valid yet? */ bool into; /* INTO supplied? */ bool strict; /* INTO STRICT flag */ |
