Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita68a132

Browse files
committed
Add VARHDRSZ where needed. Many places just used 4.
1 parent1932d92 commita68a132

File tree

13 files changed

+78
-78
lines changed

13 files changed

+78
-78
lines changed

‎src/backend/access/common/printtup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.18 1997/09/12 04:07:12 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.19 1997/12/06 22:56:20 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -124,7 +124,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
124124
{
125125
outputstr=fmgr(typoutput,attr,
126126
gettypelem(typeinfo->attrs[i]->atttypid));
127-
pq_putint(strlen(outputstr)+4,4);
127+
pq_putint(strlen(outputstr)+VARHDRSZ,VARHDRSZ);
128128
pq_putnchar(outputstr,strlen(outputstr));
129129
pfree(outputstr);
130130
}

‎src/backend/commands/async.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.24 1997/11/20 23:20:56 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.25 1997/12/06 22:56:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -619,7 +619,7 @@ Async_NotifyFrontEnd()
619619
if (whereToSendOutput==Remote)
620620
{
621621
pq_putnchar("A",1);
622-
pq_putint(ourpid,4);
622+
pq_putint(ourpid,sizeof(ourpid));
623623
pq_putstr(DatumGetName(d)->data);
624624
pq_flush();
625625
}

‎src/backend/commands/trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ CreateTrigger(CreateTrigStmt * stmt)
176176
{
177177
char*ar= (char*)lfirst(le);
178178

179-
len+=strlen(ar)+4;
179+
len+=strlen(ar)+VARHDRSZ;
180180
for (;*ar;ar++)
181181
{
182182
if (*ar=='\\')

‎src/backend/libpq/be-pqexec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.9 1997/11/10 05:15:49 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -80,7 +80,7 @@ PQfn(int fnid,
8080
{
8181
arg[i]= (char*)args[i].u.ptr;
8282
}
83-
elseif (args[i].len>4)
83+
elseif (args[i].len>sizeof(int4))
8484
{
8585
elog(WARN,"arg_length of argument %d too long",i);
8686
}
@@ -357,7 +357,7 @@ pqtest_PQfn(char *q)
357357
v=atoi(fields[j]);
358358
if (v!=0|| (v==0&&fields[j][0]=='0'))
359359
{
360-
pqargs[k].len=4;
360+
pqargs[k].len=sizeof(int4);
361361
pqargs[k].u.integer=v;
362362
printf("pqtest_PQfn: arg %d is int %d\n",k,v);/* debug */
363363
}
@@ -373,7 +373,7 @@ pqtest_PQfn(char *q)
373373
*call PQfn
374374
* ----------------
375375
*/
376-
pqres=PQfn(f,&res,4,1,pqargs,i-1);
376+
pqres=PQfn(f,&res,sizeof(int4),1,pqargs,i-1);
377377
printf("pqtest_PQfn: pqres is %s\n",pqres);/* debug */
378378

379379
/* ----------------

‎src/backend/parser/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.77 1997/12/04 23:07:23 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.78 1997/12/06 22:56:42 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -2660,7 +2660,7 @@ Character: character '(' Iconst ')'
26602660
* between this and "text" is that we blank-pad and
26612661
* truncate where necessary
26622662
*/
2663-
$$->typlen =4 + $3;
2663+
$$->typlen =VARHDRSZ + $3;
26642664
}
26652665
| character
26662666
{

‎src/backend/tcop/dest.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.14 1997/11/27 03:01:12 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.15 1997/12/06 22:57:02 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -192,9 +192,9 @@ NullCommand(CommandDest dest)
192192
nPtr= (PQNotifyList*)SLGetSucc(&nPtr->Node))
193193
{
194194
pq_putnchar("A",1);
195-
pq_putint(0,4);
195+
pq_putint(0,sizeof(int4));
196196
pq_putstr(nPtr->relname);
197-
pq_putint(nPtr->be_pid,4);
197+
pq_putint(nPtr->be_pid,sizeof(nPtr->be_pid));
198198
PQremoveNotify(nPtr);
199199
}
200200
pq_flush();
@@ -283,8 +283,8 @@ BeginCommand(char *pname,
283283
{
284284
pq_putstr(attrs[i]->attname.data);/* if 16 char name
285285
* oops.. */
286-
pq_putint((int)attrs[i]->atttypid,4);
287-
pq_putint(attrs[i]->attlen,2);
286+
pq_putint((int)attrs[i]->atttypid,sizeof(attrs[i]->atttypid));
287+
pq_putint(attrs[i]->attlen,sizeof(attrs[i]->attlen));
288288
}
289289
}
290290
break;

‎src/backend/tcop/fastpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.7 1997/09/18 20:21:58 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.8 1997/12/06 22:57:03 momjian Exp $
1111
*
1212
* NOTES
1313
* This cruft is the server side of PQfn.
@@ -101,7 +101,7 @@ SendFunctionResult(Oid fid,/* function id */
101101
{/* by-reference ... */
102102
if (retlen<0)
103103
{/* ... varlena */
104-
pq_putint(VARSIZE(retval)-VARHDRSZ,4);
104+
pq_putint(VARSIZE(retval)-VARHDRSZ,VARHDRSZ);
105105
pq_putnchar(VARDATA(retval),VARSIZE(retval)-VARHDRSZ);
106106
}
107107
else

‎src/backend/utils/adt/arrayfuncs.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.20 1997/09/18 20:22:10 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.21 1997/12/06 22:57:10 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -649,7 +649,7 @@ array_out(ArrayType *v, Oid element_type)
649649

650650
/* get a wide string to print to */
651651
p=array_dims(v,&dummy_bool);
652-
nbytes=strlen(ARR_DATA_PTR(v))+4+*(int*)p;
652+
nbytes=strlen(ARR_DATA_PTR(v))+VARHDRSZ+*(int*)p;
653653

654654
save_p= (char*)palloc(nbytes);
655655

@@ -787,18 +787,18 @@ array_dims(ArrayType *v, bool *isNull)
787787
/*
788788
* 33 since we assume 15 digits per number + ':' +'[]'
789789
*/
790-
save_p=p= (char*)palloc(nbytes+4);
791-
MemSet(save_p,0,nbytes+4);
790+
save_p=p= (char*)palloc(nbytes+VARHDRSZ);
791+
MemSet(save_p,0,nbytes+VARHDRSZ);
792792
dimv=ARR_DIMS(v);
793793
lb=ARR_LBOUND(v);
794-
p+=4;
794+
p+=VARHDRSZ;
795795
for (i=0;i<ARR_NDIM(v);i++)
796796
{
797797
sprintf(p,"[%d:%d]",lb[i],dimv[i]+lb[i]-1);
798798
p+=strlen(p);
799799
}
800-
nbytes=strlen(save_p+4)+4;
801-
memmove(save_p,&nbytes,4);
800+
nbytes=strlen(save_p+VARHDRSZ)+VARHDRSZ;
801+
memmove(save_p,&nbytes,VARHDRSZ);
802802
return (save_p);
803803
}
804804

@@ -874,7 +874,7 @@ array_ref(ArrayType *array,
874874
}
875875
if (*isNull)
876876
RETURN_NULL;
877-
if (VARSIZE(v)-4<elmlen)
877+
if (VARSIZE(v)-VARHDRSZ<elmlen)
878878
RETURN_NULL;
879879
lo_close(fd);
880880
retval= (char*)_ArrayCast((char*)VARDATA(v),reftype,elmlen);
@@ -1000,22 +1000,22 @@ array_clip(ArrayType *array,
10001000
{
10011001
char*buff;
10021002

1003-
rsize+=4;
1003+
rsize+=VARHDRSZ;
10041004
buff=palloc(rsize);
10051005
if (buff)
10061006
isDestLO= false;
10071007
if (ARR_IS_CHUNKED(array))
10081008
{
1009-
_ReadChunkArray(lowerIndx,upperIndx,len,fd,&(buff[4]),
1009+
_ReadChunkArray(lowerIndx,upperIndx,len,fd,&(buff[VARHDRSZ]),
10101010
array,0,isNull);
10111011
}
10121012
else
10131013
{
1014-
_ReadArray(lowerIndx,upperIndx,len,fd, (int)&(buff[4]),
1014+
_ReadArray(lowerIndx,upperIndx,len,fd, (int)&(buff[VARHDRSZ]),
10151015
array,
10161016
0,isNull);
10171017
}
1018-
memmove(buff,&rsize,4);
1018+
memmove(buff,&rsize,VARHDRSZ);
10191019
#ifdefLOARRAY
10201020
if (!*isNull)
10211021
bytes=LOwrite(newfd, (structvarlena*)buff);
@@ -1131,15 +1131,15 @@ array_set(ArrayType *array,
11311131
#endif
11321132
if (lo_lseek(fd,offset,SEEK_SET)<0)
11331133
return ((char*)array);
1134-
v= (structvarlena*)palloc(elmlen+4);
1135-
VARSIZE(v)=elmlen+4;
1134+
v= (structvarlena*)palloc(elmlen+VARHDRSZ);
1135+
VARSIZE(v)=elmlen+VARHDRSZ;
11361136
ArrayCastAndSet(dataPtr, (bool)reftype,elmlen,VARDATA(v));
11371137
#ifdefLOARRAY
11381138
n=LOwrite(fd,v);
11391139
#endif
11401140

11411141
/*
1142-
* if (n < VARSIZE(v) -4) RETURN_NULL;
1142+
* if (n < VARSIZE(v) -VARHDRSZ) RETURN_NULL;
11431143
*/
11441144
pfree(v);
11451145
lo_close(fd);
@@ -1692,7 +1692,7 @@ _LOtransfer(char **destfd,
16921692
{
16931693
#ifdefLOARRAY
16941694
v= (structvarlena*)LOread((int)*srcfd,inc);
1695-
if (VARSIZE(v)-4<inc)
1695+
if (VARSIZE(v)-VARHDRSZ<inc)
16961696
{
16971697
pfree(v);
16981698
return (-1);

‎src/backend/utils/adt/chunk.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.10 1997/09/08 21:48:19 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.11 1997/12/06 22:57:12 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -271,7 +271,7 @@ get_next(int d[], int k, int C, int dmax[])
271271
}
272272

273273
#ifdefLOARRAY
274-
staticchara_chunk[BLCKSZ+4];/*4 since a_chunk is in varlena format */
274+
staticchara_chunk[BLCKSZ+VARHDRSZ];/*VARHDRSZ since a_chunk is in varlena format */
275275

276276
#endif
277277

@@ -318,16 +318,16 @@ _ConvertToChunkFile(int n,
318318
csize *=C[i];
319319
}
320320
csize *=baseSize;
321-
temp=csize+4;
322-
memmove(a_chunk,&temp,4);
321+
temp=csize+VARHDRSZ;
322+
memmove(a_chunk,&temp,VARHDRSZ);
323323

324324
mda_get_prod(n,dim,PX);
325325
mda_get_offset_values(n,dist,PX,C);
326326
for (i=0;i<n;dist[i] *=baseSize,i++)
327327
;
328328
do
329329
{
330-
read_chunk(chunk_no,C,&(a_chunk[4]),srcfd,n,baseSize,PX,dist);
330+
read_chunk(chunk_no,C,&(a_chunk[VARHDRSZ]),srcfd,n,baseSize,PX,dist);
331331
write_chunk((structvarlena*)a_chunk,destfd);
332332
}while (next_tuple(n,chunk_no,max_chunks)!=-1);
333333
}
@@ -417,7 +417,7 @@ seek_and_read(int pos, int size, char buff[], int fp, int from)
417417
#ifdefLOARRAY
418418
v= (structvarlena*)LOread(fp,size);
419419
#endif
420-
if (VARSIZE(v)-4<size)
420+
if (VARSIZE(v)-VARHDRSZ<size)
421421
elog(WARN,"File read error");
422422
memmove(buff,VARDATA(v),size);
423423
pfree(v);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp