1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Make ALTER TABLE RENAME on a view rename the view's on-select rule too.

Needed to keep pg_dump from getting confused.
This commit is contained in:
Tom Lane
2001-08-12 21:35:19 +00:00
parent a0c449a0f8
commit 1b5cffacdf
8 changed files with 117 additions and 45 deletions

View File

@ -6,11 +6,10 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: view.c,v 1.55 2001/08/10 18:57:35 tgl Exp $
* $Id: view.c,v 1.56 2001/08/12 21:35:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/xact.h"
@ -24,10 +23,8 @@
#include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteManip.h"
#include "rewrite/rewriteRemove.h"
#include "rewrite/rewriteSupport.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
/*---------------------------------------------------------------------
* DefineVirtualRelation
@ -100,35 +97,6 @@ DefineVirtualRelation(char *relname, List *tlist)
DefineRelation(createStmt, RELKIND_VIEW);
}
/*------------------------------------------------------------------
* makeViewRetrieveRuleName
*
* Given a view name, returns the name for the 'on retrieve to "view"'
* rule.
*------------------------------------------------------------------
*/
char *
MakeRetrieveViewRuleName(char *viewName)
{
char *buf;
int buflen,
maxlen;
buflen = strlen(viewName) + 5;
buf = palloc(buflen);
snprintf(buf, buflen, "_RET%s", viewName);
/* clip to less than NAMEDATALEN bytes, if necessary */
#ifdef MULTIBYTE
maxlen = pg_mbcliplen(buf, strlen(buf), NAMEDATALEN - 1);
#else
maxlen = NAMEDATALEN - 1;
#endif
if (maxlen < buflen)
buf[maxlen] = '\0';
return buf;
}
static RuleStmt *
FormViewRetrieveRule(char *viewName, Query *viewParse)
{