From 0ba0e321726e02c54c4440282b51f25078fe8d81 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 12 Sep 2000 04:15:58 +0000 Subject: O.K. - Here's the multibyte aware version of my patch to fix the truncation of the rulename autogenerated during a CREATE VIEW. I've modified all the places in the backend that want to construct the rulename to use the MakeRetrieveViewRuleName(), where I put the #ifdef MULTIBYTE, so that's the only place that knows how to construct a view rulename. Except pg_dump, where I replicated the code, since it's a standalone binary. The only effect the enduser will see is that views with names len(name) > NAMEDATALEN-4 will fail to be created, if the derived rulename clases with an existing rule: i.e. the user is trying to create two views with long names whose first difference is past NAMEDATALEN-4 (but before NAMEDATALEN: that'll error out after the viewname truncation.) In no case will the user get left with a table without a view rule, as the current code does. Ross Reedstrom --- src/backend/commands/view.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/backend/commands/view.c') diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 8503eb3a7eb..01e23d13150 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: view.c,v 1.45 2000/07/04 06:11:30 tgl Exp $ + * $Id: view.c,v 1.46 2000/09/12 04:15:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,6 +120,14 @@ MakeRetrieveViewRuleName(char *viewName) buf = palloc(strlen(viewName) + 5); snprintf(buf, strlen(viewName) + 5, "_RET%s", viewName); +#ifdef MULTIBYTE + int len; + len = pg_mbcliplen(buf,strlen(buf),NAMEDATALEN-1); + buf[len] = '\0'; +#else + buf[NAMEDATALEN-1] = '\0'; +#endif + return buf; } -- cgit v1.2.3