|
6 | 6 | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 |
| - *$Id: view.c,v 1.51 2000/12/21 17:36:15 tgl Exp $ |
| 9 | + *$Id: view.c,v 1.52 2001/01/03 18:43:09 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
@@ -110,19 +110,20 @@ char *
|
110 | 110 | MakeRetrieveViewRuleName(char*viewName)
|
111 | 111 | {
|
112 | 112 | char*buf;
|
113 |
| -#ifdefMULTIBYTE |
114 |
| -intlen; |
115 |
| -#endif |
116 |
| - |
117 |
| -buf=palloc(strlen(viewName)+5); |
118 |
| -snprintf(buf,strlen(viewName)+5,"_RET%s",viewName); |
| 113 | +intbuflen, |
| 114 | +maxlen; |
119 | 115 |
|
| 116 | +buflen=strlen(viewName)+5; |
| 117 | +buf=palloc(buflen); |
| 118 | +snprintf(buf,buflen,"_RET%s",viewName); |
| 119 | +/* clip to less than NAMEDATALEN bytes, if necessary */ |
120 | 120 | #ifdefMULTIBYTE
|
121 |
| -len=pg_mbcliplen(buf,strlen(buf),NAMEDATALEN-1); |
122 |
| -buf[len]='\0'; |
| 121 | +maxlen=pg_mbcliplen(buf,strlen(buf),NAMEDATALEN-1); |
123 | 122 | #else
|
124 |
| -buf[NAMEDATALEN-1]='\0'; |
| 123 | +maxlen=NAMEDATALEN-1; |
125 | 124 | #endif
|
| 125 | +if (maxlen<buflen) |
| 126 | +buf[maxlen]='\0'; |
126 | 127 |
|
127 | 128 | returnbuf;
|
128 | 129 | }
|
|