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

Commit794ec7b

Browse files
committed
Department of second thoughts: further experimentation with CREATE OR REPLACE
VIEW suggests that it'd be worth spelling the error messages out in a littlemore detail. This seems to help with localizing the problem.
1 parent1b92aeb commit794ec7b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

‎src/backend/commands/view.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.109 2008/12/15 21:35:31 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.110 2008/12/16 00:56:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -29,6 +29,7 @@
2929
#include"rewrite/rewriteManip.h"
3030
#include"rewrite/rewriteSupport.h"
3131
#include"utils/acl.h"
32+
#include"utils/builtins.h"
3233
#include"utils/lsyscache.h"
3334
#include"utils/rel.h"
3435

@@ -263,7 +264,7 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc)
263264
Form_pg_attributenewattr=newdesc->attrs[i];
264265
Form_pg_attributeoldattr=olddesc->attrs[i];
265266

266-
/* XXX not right, but we don't support DROP COL on view anyway */
267+
/* XXXmsgnot right, but we don't support DROP COL on view anyway */
267268
if (newattr->attisdropped!=oldattr->attisdropped)
268269
ereport(ERROR,
269270
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -272,15 +273,20 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc)
272273
if (strcmp(NameStr(newattr->attname),NameStr(oldattr->attname))!=0)
273274
ereport(ERROR,
274275
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
275-
errmsg("cannot change name of view column \"%s\"",
276-
NameStr(oldattr->attname))));
276+
errmsg("cannot change name of view column \"%s\" to \"%s\"",
277+
NameStr(oldattr->attname),
278+
NameStr(newattr->attname))));
277279
/* XXX would it be safe to allow atttypmod to change? Not sure */
278280
if (newattr->atttypid!=oldattr->atttypid||
279281
newattr->atttypmod!=oldattr->atttypmod)
280282
ereport(ERROR,
281283
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
282-
errmsg("cannot change data type of view column \"%s\"",
283-
NameStr(oldattr->attname))));
284+
errmsg("cannot change data type of view column \"%s\" from %s to %s",
285+
NameStr(oldattr->attname),
286+
format_type_with_typemod(oldattr->atttypid,
287+
oldattr->atttypmod),
288+
format_type_with_typemod(newattr->atttypid,
289+
newattr->atttypmod))));
284290
/* We can ignore the remaining attributes of an attribute... */
285291
}
286292

‎src/test/regress/expected/create_view.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ ERROR: cannot drop columns from view
5353
-- should fail
5454
CREATE OR REPLACE VIEW viewtest AS
5555
SELECT 1, * FROM viewtest_tbl;
56-
ERROR: cannot change name of view column "a"
56+
ERROR: cannot change name of view column "a" to "?column?"
5757
-- should fail
5858
CREATE OR REPLACE VIEW viewtest AS
5959
SELECT a, b::numeric FROM viewtest_tbl;
60-
ERROR: cannot change data type of view column "b"
60+
ERROR: cannot change data type of view column "b" from integer to numeric
6161
-- should work
6262
CREATE OR REPLACE VIEW viewtest AS
6363
SELECT a, b, 0 AS c FROM viewtest_tbl;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp