diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 15a1dab8c5..1bd19b4730 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -423,8 +423,12 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, snamespace = get_namespace_name(snamespaceid); } sname = rv->relname; - /* Remove the SEQUENCE NAME item from seqoptions */ - seqoptions = list_delete_nth_cell(seqoptions, nameEl_idx); + + /* + * Remove the SEQUENCE NAME item from seqoptions. We'd better make a + * copy first so as we're not modifying the passed in List. + */ + seqoptions = list_delete_nth_cell(list_copy(seqoptions), nameEl_idx); } else {