Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b7d49a4

Browse files
committed
Drive a stake through the heart of the last use of MAX_PARSE_BUFFER
in the backend. Still a few stragglers, but we're getting closer to being rid of query length limits...
1 parent 8e35bbd commit b7d49a4

File tree

1 file changed

+25
-21
lines changed
  • src/backend/utils/adt

1 file changed

+25
-21
lines changed

src/backend/utils/adt/acl.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.40 1999/07/17 20:17:52 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.41 1999/10/18 03:32:29 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include <ctype.h>
15+
1516
#include "postgres.h"
1617

1718
#include "catalog/catalog.h"
1819
#include "catalog/pg_shadow.h"
1920
#include "catalog/pg_type.h"
20-
#include "miscadmin.h"
21+
#include "lib/stringinfo.h"
2122
#include "utils/acl.h"
2223
#include "utils/memutils.h"
2324
#include "utils/syscache.h"
@@ -41,7 +42,7 @@ static char *aclparse(char *s, AclItem *aip, unsigned *modechg);
4142
* the string position in 's' that points to the next non-space character
4243
* in 's', after any quotes. Also:
4344
* - loads the identifier into 'name'. (If no identifier is found, 'name'
44-
* contains an empty string).
45+
* contains an empty string.) name must be NAMEDATALEN bytes.
4546
*/
4647
static char *
4748
getid(char *s, char *n)
@@ -69,9 +70,9 @@ getid(char *s, char *n)
6970
in_quotes = 0;
7071
}
7172
}
72-
if (len > sizeof(NameData))
73-
elog(ERROR, "getid: identifier cannot be >%d characters",
74-
sizeof(NameData));
73+
if (len >= NAMEDATALEN)
74+
elog(ERROR, "getid: identifier must be <%d characters",
75+
NAMEDATALEN);
7576
if (len > 0)
7677
memmove(n, id, len);
7778
n[len] = '\0';
@@ -205,10 +206,10 @@ makeacl(int n)
205206
Size size;
206207

207208
if (n < 0)
208-
elog(ERROR, "makeacl: invalid size: %d\n", n);
209+
elog(ERROR, "makeacl: invalid size: %d", n);
209210
size = ACL_N_SIZE(n);
210211
if (!(new_acl = (Acl *) palloc(size)))
211-
elog(ERROR, "makeacl: palloc failed on %d\n", size);
212+
elog(ERROR, "makeacl: palloc failed on %d", size);
212213
MemSet((char *) new_acl, 0, size);
213214
new_acl->size = size;
214215
new_acl->ndim = 1;
@@ -679,34 +680,37 @@ ChangeACLStmt *
679680
makeAclStmt(char *privileges, List *rel_list, char *grantee,
680681
char grant_or_revoke)
681682
{
682-
ChangeACLStmt *n = makeNode(ChangeACLStmt);
683-
char str[MAX_PARSE_BUFFER];
683+
ChangeACLStmt *n = makeNode(ChangeACLStmt);
684+
StringInfoData str;
685+
686+
initStringInfo(&str);
684687

685688
/* see comment in pg_type.h */
686689
Assert(ACLITEMSIZE == sizeof(AclItem));
687690

688691
n->aclitem = (AclItem *) palloc(sizeof(AclItem));
689692

690-
/* the grantee string is "G <group_name>", "U <user_name>", or "ALL" */
693+
/* the grantee string is "G <group_name>", "U <user_name>", or "ALL" */
691694
if (grantee[0] == 'G') /* group permissions */
692695
{
693-
sprintf(str, "%s %c%s%c%c%s",
694-
ACL_IDTYPE_GID_KEYWORD,
695-
'"', grantee + 2, '"', grant_or_revoke, privileges);
696+
appendStringInfo(&str, "%s \"%s\"%c%s",
697+
ACL_IDTYPE_GID_KEYWORD,
698+
grantee + 2, grant_or_revoke, privileges);
696699
}
697700
else if (grantee[0] == 'U') /* user permission */
698701
{
699-
sprintf(str, "%s %c%s%c%c%s",
700-
ACL_IDTYPE_UID_KEYWORD,
701-
'"', grantee + 2, '"', grant_or_revoke, privileges);
702+
appendStringInfo(&str, "%s \"%s\"%c%s",
703+
ACL_IDTYPE_UID_KEYWORD,
704+
grantee + 2, grant_or_revoke, privileges);
702705
}
703706
else
704-
/* all permission */
705707
{
706-
sprintf(str, "%c%s",
707-
grant_or_revoke, privileges);
708+
/* all permission */
709+
appendStringInfo(&str, "%c%s",
710+
grant_or_revoke, privileges);
708711
}
709712
n->relNames = rel_list;
710-
aclparse(str, n->aclitem, (unsigned *) &n->modechg);
713+
aclparse(str.data, n->aclitem, (unsigned *) &n->modechg);
714+
pfree(str.data);
711715
return n;
712716
}

0 commit comments

Comments
 (0)