|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.67 2002/04/18 20:01:09 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.68 2002/04/19 23:13:54 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -176,7 +176,6 @@ DefineQueryRewrite(RuleStmt *stmt) |
176 | 176 | { |
177 | 177 | List*tllist; |
178 | 178 | inti; |
179 | | -char*expected_name; |
180 | 179 |
|
181 | 180 | /* |
182 | 181 | * So there cannot be INSTEAD NOTHING, ... |
@@ -265,15 +264,26 @@ DefineQueryRewrite(RuleStmt *stmt) |
265 | 264 | } |
266 | 265 |
|
267 | 266 | /* |
268 | | - * ... and finally the rule must be named_RETviewname. |
| 267 | + * ... and finally the rule must be named_RETURN. |
269 | 268 | */ |
270 | | -expected_name=MakeRetrieveViewRuleName(event_obj->relname); |
271 | | -if (strcmp(expected_name,stmt->rulename)!=0) |
| 269 | +if (strcmp(stmt->rulename,ViewSelectRuleName)!=0) |
272 | 270 | { |
273 | | -elog(ERROR,"view rule for \"%s\" must be named \"%s\"", |
274 | | -event_obj->relname,expected_name); |
| 271 | +/* |
| 272 | + * In versions before 7.3, the expected name was _RETviewname. |
| 273 | + * For backwards compatibility with old pg_dump output, accept |
| 274 | + * that and silently change it to _RETURN. Since this is just |
| 275 | + * a quick backwards-compatibility hack, limit the number of |
| 276 | + * characters checked to a few less than NAMEDATALEN; this |
| 277 | + * saves having to worry about where a multibyte character might |
| 278 | + * have gotten truncated. |
| 279 | + */ |
| 280 | +if (strncmp(stmt->rulename,"_RET",4)!=0|| |
| 281 | +strncmp(stmt->rulename+4,event_obj->relname, |
| 282 | +NAMEDATALEN-4-4)!=0) |
| 283 | +elog(ERROR,"view rule for \"%s\" must be named \"%s\"", |
| 284 | +event_obj->relname,ViewSelectRuleName); |
| 285 | +stmt->rulename=pstrdup(ViewSelectRuleName); |
275 | 286 | } |
276 | | -pfree(expected_name); |
277 | 287 |
|
278 | 288 | /* |
279 | 289 | * Are we converting a relation to a view? |
@@ -418,9 +428,7 @@ setRuleCheckAsUser_walker(Node *node, Oid *context) |
418 | 428 | /* |
419 | 429 | * Rename an existing rewrite rule. |
420 | 430 | * |
421 | | - * There is not currently a user command to invoke this directly |
422 | | - * (perhaps there should be). But we need it anyway to rename the |
423 | | - * ON SELECT rule associated with a view, when the view is renamed. |
| 431 | + * This is unused code at the moment. |
424 | 432 | */ |
425 | 433 | void |
426 | 434 | RenameRewriteRule(OidowningRel,constchar*oldName, |
|