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

Commit ede5a41

Browse files
committed
Clean up maximum rewrite tuple length.
1 parent eba4184 commit ede5a41

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/backend/rewrite/rewriteDefine.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.29 1999/05/25 16:10:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.30 1999/07/04 05:16:05 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -16,7 +16,9 @@
1616

1717
#include "postgres.h"
1818

19+
#include "access/htup.h"
1920
#include "access/heapam.h" /* access methods like amopenr */
21+
#include "catalog/pg_rewrite.h"
2022
#include "nodes/parsenodes.h"
2123
#include "nodes/pg_list.h" /* for Lisp support */
2224
#include "parser/parse_relation.h"
@@ -32,14 +34,6 @@
3234

3335
Oid LastOidProcessed = InvalidOid;
3436

35-
/*
36-
* This is too small for many rule plans, but it'll have to do for now.
37-
* Rule plans, etc will eventually have to be large objects.
38-
*
39-
* should this be smaller?
40-
*/
41-
#define RULE_PLAN_SIZE BLCKSZ
42-
4337
static void
4438
strcpyq(char *dest, char *source)
4539
{
@@ -84,9 +78,9 @@ InsertRule(char *rulname,
8478
bool evinstead,
8579
char *actiontree)
8680
{
87-
static char rulebuf[RULE_PLAN_SIZE];
88-
static char actionbuf[RULE_PLAN_SIZE];
89-
static char qualbuf[RULE_PLAN_SIZE];
81+
static char rulebuf[MaxAttrSize];
82+
static char actionbuf[MaxAttrSize];
83+
static char qualbuf[MaxAttrSize];
9084
Oid eventrel_oid = InvalidOid;
9185
AttrNumber evslot_index = InvalidAttrNumber;
9286
Relation eventrel = NULL;
@@ -124,8 +118,8 @@ InsertRule(char *rulname,
124118
(rulename, ev_type, ev_class, ev_attr, ev_action, ev_qual, is_instead) VALUES \
125119
('%s', %d::char, %u::oid, %d::int2, '%s'::text, '%s'::text, \
126120
'%s'::bool);";
127-
if (strlen(template) + strlen(rulname) + strlen(actionbuf) +
128-
strlen(qualbuf) + 20 /* fudge fac */ > RULE_PLAN_SIZE)
121+
if (sizeof(FormData_pg_rewrite) + strlen(actionbuf) +
122+
strlen(qualbuf) > MaxAttrSize)
129123
elog(ERROR, "DefineQueryRewrite: rule plan string too big.");
130124
sprintf(rulebuf, template,
131125
rulname, evtype, eventrel_oid, evslot_index, actionbuf,

0 commit comments

Comments
 (0)