1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +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

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.48 2001/03/22 03:59:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.49 2001/08/12 21:35:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -20,15 +20,52 @@
#include "rewrite/rewriteSupport.h"
#include "utils/syscache.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
/*
* Is there a rule by the given name?
*/
bool
IsDefinedRewriteRule(char *ruleName)
IsDefinedRewriteRule(const char *ruleName)
{
return SearchSysCacheExists(RULENAME,
PointerGetDatum(ruleName),
0, 0, 0);
}
/*
* makeViewRetrieveRuleName
*
* Given a view name, returns the name for the associated ON SELECT rule.
*
* XXX this is not the only place in the backend that knows about the _RET
* name-forming convention.
*/
char *
MakeRetrieveViewRuleName(const 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;
}
/*
* SetRelationRuleStatus
* Set the value of the relation's relhasrules field in pg_class;