Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit73d78e1

Browse files
committed
Throw error for ALTER TABLE RESET of an invalid option
Also adjust pg_upgrade to not use this method for optional TOAST tablecreation.Patch by Fabrízio de Royes Mello
1 parentebe30ad commit73d78e1

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

‎contrib/pg_upgrade/dump.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ optionally_create_toast_tables(void)
115115
"c.relkind IN ('r', 'm') AND "
116116
"c.reltoastrelid = 0");
117117

118+
/* Suppress NOTICE output from non-existant constraints */
119+
PQclear(executeQueryOrDie(conn,"SET client_min_messages = warning;"));
120+
PQclear(executeQueryOrDie(conn,"SET log_min_messages = warning;"));
121+
118122
ntups=PQntuples(res);
119123
i_nspname=PQfnumber(res,"nspname");
120124
i_relname=PQfnumber(res,"relname");
@@ -125,13 +129,16 @@ optionally_create_toast_tables(void)
125129
OPTIONALLY_CREATE_TOAST_OID));
126130

127131
/* dummy command that also triggers check for required TOAST table */
128-
PQclear(executeQueryOrDie(conn,"ALTER TABLE %s.%sRESET (binary_upgrade_dummy_option);",
132+
PQclear(executeQueryOrDie(conn,"ALTER TABLE %s.%sDROP CONSTRAINT IF EXISTS binary_upgrade_dummy_constraint;",
129133
quote_identifier(PQgetvalue(res,rowno,i_nspname)),
130134
quote_identifier(PQgetvalue(res,rowno,i_relname))));
131135
}
132136

133137
PQclear(res);
134138

139+
PQclear(executeQueryOrDie(conn,"RESET client_min_messages;"));
140+
PQclear(executeQueryOrDie(conn,"RESET log_min_messages;"));
141+
135142
PQfinish(conn);
136143
}
137144

‎src/backend/access/common/reloptions.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ static void initialize_reloptions(void);
307307
staticvoidparse_one_reloption(relopt_value*option,char*text_str,
308308
inttext_len,boolvalidate);
309309

310+
staticboolis_valid_reloption(char*name);
311+
310312
/*
311313
* initialize_reloptions
312314
*initialization routine, must be called before parsing
@@ -381,6 +383,25 @@ initialize_reloptions(void)
381383
need_initialization= false;
382384
}
383385

386+
/*
387+
* is_valid_reloption
388+
*check if a reloption exists
389+
*
390+
*/
391+
staticbool
392+
is_valid_reloption(char*name)
393+
{
394+
inti;
395+
396+
for (i=0;relOpts[i];i++)
397+
{
398+
if (pg_strcasecmp(relOpts[i]->name,name)==0)
399+
return true;
400+
}
401+
402+
return false;
403+
}
404+
384405
/*
385406
* add_reloption_kind
386407
*Create a new relopt_kind value, to be used in custom reloptions by
@@ -672,6 +693,11 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace,
672693

673694
if (isReset)
674695
{
696+
if (!is_valid_reloption(def->defname))
697+
ereport(ERROR,
698+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
699+
errmsg("unrecognized parameter \"%s\"",def->defname)));
700+
675701
if (def->arg!=NULL)
676702
ereport(ERROR,
677703
(errcode(ERRCODE_SYNTAX_ERROR),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp