diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 530a1ae..4a5b767 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -307,6 +307,8 @@ static void initialize_reloptions(void); static void parse_one_reloption(relopt_value *option, char *text_str, int text_len, bool validate); +static bool is_valid_reloption(char *name); + /* * initialize_reloptions * initialization routine, must be called before parsing @@ -382,6 +384,25 @@ initialize_reloptions(void) } /* + * is_valid_reloption + * check if a reloption exists + * + */ +static bool +is_valid_reloption(char *name) +{ + int i; + + for (i = 0; relOpts[i]; i++) + { + if (pg_strcasecmp(relOpts[i]->name, name) == 0) + return true; + } + + return false; +} + +/* * add_reloption_kind * Create a new relopt_kind value, to be used in custom reloptions by * user-defined AMs. @@ -674,6 +695,11 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace, if (isReset) { + if (!is_valid_reloption(def->defname)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("unrecognized parameter \"%s\"", def->defname))); + if (def->arg != NULL) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 0f0c638..195103e 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -7,6 +7,14 @@ COMMENT ON TABLE tmp_wrong IS 'table comment'; ERROR: relation "tmp_wrong" does not exist COMMENT ON TABLE tmp IS 'table comment'; COMMENT ON TABLE tmp IS NULL; +ALTER TABLE tmp SET (fillfactor=70); +ALTER TABLE tmp RESET (fillfactor, noname); +ERROR: unrecognized parameter "noname" +ALTER TABLE tmp RESET (fillfactor=70); +ERROR: RESET must not include values for parameters +ALTER TABLE tmp RESET (fillfactor); +ALTER TABLE tmp RESET (noname); +ERROR: unrecognized parameter "noname" ALTER TABLE tmp ADD COLUMN xmin integer; -- fails ERROR: column name "xmin" conflicts with a system column name ALTER TABLE tmp ADD COLUMN a int4 default 3; diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 87973c1..2cb31f2 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -9,6 +9,16 @@ COMMENT ON TABLE tmp_wrong IS 'table comment'; COMMENT ON TABLE tmp IS 'table comment'; COMMENT ON TABLE tmp IS NULL; +ALTER TABLE tmp SET (fillfactor=70); + +ALTER TABLE tmp RESET (fillfactor, noname); + +ALTER TABLE tmp RESET (fillfactor=70); + +ALTER TABLE tmp RESET (fillfactor); + +ALTER TABLE tmp RESET (noname); + ALTER TABLE tmp ADD COLUMN xmin integer; -- fails ALTER TABLE tmp ADD COLUMN a int4 default 3;