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

Commit549dae0

Browse files
committed
Fix problems with incomplete attempt to prohibit OIDS with MVs.
Problem with assertion failure in restoring from pg_dump outputreported by Joachim Wieland.Review and suggestions by Tom Lane and Robert Haas.
1 parent4912385 commit549dae0

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

‎doc/src/sgml/ref/create_materialized_view.sgml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ CREATE [ UNLOGGED ] MATERIALIZED VIEW <replaceable>table_name</replaceable>
4444
<command>CREATE MATERIALIZED VIEW</command> is similar to
4545
<command>CREATE TABLE AS</>, except that it also remembers the query used
4646
to initialize the view, so that it can be refreshed later upon demand.
47+
A materialized view has many of the same properties as a table, but there
48+
is no support for temporary materialized views or automatic generation of
49+
OIDs.
4750
</para>
4851
</refsect1>
4952

@@ -88,7 +91,9 @@ CREATE [ UNLOGGED ] MATERIALIZED VIEW <replaceable>table_name</replaceable>
8891
This clause specifies optional storage parameters for the new
8992
materialized view; see <xref linkend="sql-createtable-storage-parameters"
9093
endterm="sql-createtable-storage-parameters-title"> for more
91-
information.
94+
information. All parameters supported for <literal>CREATE
95+
TABLE</literal> are also supported for <literal>CREATE MATERIALIZED
96+
VIEW</literal> with the exception of <literal>OIDS</literal>.
9297
See <xref linkend="sql-createtable"> for more information.
9398
</para>
9499
</listitem>

‎src/backend/commands/createas.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,15 @@ GetIntoRelEFlags(IntoClause *intoClause)
218218
* because it doesn't have enough information to do so itself (since we
219219
* can't build the target relation until after ExecutorStart).
220220
*/
221-
if (interpretOidsOption(intoClause->options))
221+
if (interpretOidsOption(intoClause->options,intoClause->relkind))
222222
flags=EXEC_FLAG_WITH_OIDS;
223223
else
224224
flags=EXEC_FLAG_WITHOUT_OIDS;
225225

226+
Assert(intoClause->relkind!=RELKIND_MATVIEW||
227+
(flags& (EXEC_FLAG_WITH_OIDS |EXEC_FLAG_WITHOUT_OIDS))==
228+
EXEC_FLAG_WITHOUT_OIDS);
229+
226230
if (intoClause->skipData)
227231
flags |=EXEC_FLAG_WITH_NO_DATA;
228232

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId)
559559
*/
560560
descriptor=BuildDescForRelation(schema);
561561

562-
localHasOids=interpretOidsOption(stmt->options);
562+
localHasOids=interpretOidsOption(stmt->options,relkind);
563563
descriptor->tdhasoid= (localHasOids||parentOidCount>0);
564564

565565
/*

‎src/backend/parser/parse_clause.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,14 @@ interpretInhOption(InhOption inhOpt)
243243
* table/result set should be created with OIDs. This needs to be done after
244244
* parsing the query string because the return value can depend upon the
245245
* default_with_oids GUC var.
246+
*
247+
* Materialized views are handled here rather than reloptions.c because that
248+
* code explicitly punts checking for oids to here. We prohibit any explicit
249+
* specification of the oids option for a materialized view, and indicate that
250+
* oids are not needed if we don't get an error.
246251
*/
247252
bool
248-
interpretOidsOption(List*defList)
253+
interpretOidsOption(List*defList,charrelkind)
249254
{
250255
ListCell*cell;
251256

@@ -256,9 +261,19 @@ interpretOidsOption(List *defList)
256261

257262
if (def->defnamespace==NULL&&
258263
pg_strcasecmp(def->defname,"oids")==0)
264+
{
265+
if (relkind==RELKIND_MATVIEW)
266+
ereport(ERROR,
267+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
268+
errmsg("unrecognized parameter \"%s\"","oids")));
269+
259270
returndefGetBoolean(def);
271+
}
260272
}
261273

274+
if (relkind==RELKIND_MATVIEW)
275+
return false;
276+
262277
/* OIDS option was not specified, so use default. */
263278
returndefault_with_oids;
264279
}

‎src/backend/parser/parse_utilcmd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,14 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
199199
{
200200
cxt.stmtType="CREATE FOREIGN TABLE";
201201
cxt.isforeign= true;
202+
cxt.hasoids=interpretOidsOption(stmt->options,
203+
RELKIND_FOREIGN_TABLE);
202204
}
203205
else
204206
{
205207
cxt.stmtType="CREATE TABLE";
206208
cxt.isforeign= false;
209+
cxt.hasoids=interpretOidsOption(stmt->options,RELKIND_RELATION);
207210
}
208211
cxt.relation=stmt->relation;
209212
cxt.rel=NULL;
@@ -217,7 +220,6 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
217220
cxt.blist=NIL;
218221
cxt.alist=NIL;
219222
cxt.pkey=NULL;
220-
cxt.hasoids=interpretOidsOption(stmt->options);
221223

222224
Assert(!stmt->ofTypename|| !stmt->inhRelations);/* grammar enforces */
223225

‎src/include/parser/parse_clause.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern void transformFromClause(ParseState *pstate, List *frmList);
2020
externintsetTargetTable(ParseState*pstate,RangeVar*relation,
2121
boolinh,boolalsoSource,AclModerequiredPerms);
2222
externboolinterpretInhOption(InhOptioninhOpt);
23-
externboolinterpretOidsOption(List*defList);
23+
externboolinterpretOidsOption(List*defList,charrelkind);
2424

2525
externNode*transformWhereClause(ParseState*pstate,Node*clause,
2626
ParseExprKindexprKind,constchar*constructName);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp