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

Commit31079a4

Browse files
committed
Replace remaining uses of pq_sendint with pq_sendint{8,16,32}.
pq_sendint() remains, so extension code doesn't unnecessarily break.Author: Andres FreundDiscussion:https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de
1 parent5232872 commit31079a4

File tree

30 files changed

+160
-163
lines changed

30 files changed

+160
-163
lines changed

‎contrib/hstore/hstore_io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,23 +1207,23 @@ hstore_send(PG_FUNCTION_ARGS)
12071207

12081208
pq_begintypsend(&buf);
12091209

1210-
pq_sendint(&buf,count,4);
1210+
pq_sendint32(&buf,count);
12111211

12121212
for (i=0;i<count;i++)
12131213
{
12141214
int32keylen=HSTORE_KEYLEN(entries,i);
12151215

1216-
pq_sendint(&buf,keylen,4);
1216+
pq_sendint32(&buf,keylen);
12171217
pq_sendtext(&buf,HSTORE_KEY(entries,base,i),keylen);
12181218
if (HSTORE_VALISNULL(entries,i))
12191219
{
1220-
pq_sendint(&buf,-1,4);
1220+
pq_sendint32(&buf,-1);
12211221
}
12221222
else
12231223
{
12241224
int32vallen=HSTORE_VALLEN(entries,i);
12251225

1226-
pq_sendint(&buf,vallen,4);
1226+
pq_sendint32(&buf,vallen);
12271227
pq_sendtext(&buf,HSTORE_VAL(entries,base,i),vallen);
12281228
}
12291229
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
3434
inti;
3535

3636
pq_beginmessage(&buf,'T');/* RowDescription */
37-
pq_sendint(&buf,tupdesc->natts,2);
37+
pq_sendint16(&buf,tupdesc->natts);
3838

3939
for (i=0;i<tupdesc->natts;++i)
4040
{
4141
Form_pg_attributeattr=TupleDescAttr(tupdesc,i);
4242

4343
pq_sendstring(&buf,NameStr(attr->attname));
44-
pq_sendint(&buf,0,4);/* table oid */
45-
pq_sendint(&buf,0,2);/* attnum */
46-
pq_sendint(&buf, (int)attr->atttypid,4);
47-
pq_sendint(&buf,attr->attlen,2);
48-
pq_sendint(&buf,attr->atttypmod,4);
49-
pq_sendint(&buf,0,2);/* format code */
44+
pq_sendint32(&buf,0);/* table oid */
45+
pq_sendint16(&buf,0);/* attnum */
46+
pq_sendint32(&buf, (int)attr->atttypid);
47+
pq_sendint16(&buf,attr->attlen);
48+
pq_sendint32(&buf,attr->atttypmod);
49+
pq_sendint16(&buf,0);/* format code */
5050
}
5151

5252
pq_endmessage(&buf);
@@ -67,7 +67,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
6767

6868
/* Prepare and send message */
6969
pq_beginmessage(&buf,'D');
70-
pq_sendint(&buf,tupdesc->natts,2);
70+
pq_sendint16(&buf,tupdesc->natts);
7171

7272
for (i=0;i<tupdesc->natts;++i)
7373
{
@@ -76,7 +76,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
7676

7777
if (slot->tts_isnull[i])
7878
{
79-
pq_sendint(&buf,-1,4);
79+
pq_sendint32(&buf,-1);
8080
continue;
8181
}
8282

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
395395
*/
396396
pq_beginmessage_reuse(buf,'D');
397397

398-
pq_sendint(buf,natts,2);
398+
pq_sendint16(buf,natts);
399399

400400
/*
401401
* send the attributes of this tuple
@@ -407,7 +407,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
407407

408408
if (slot->tts_isnull[i])
409409
{
410-
pq_sendint(buf,-1,4);
410+
pq_sendint32(buf,-1);
411411
continue;
412412
}
413413

@@ -436,7 +436,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
436436
bytea*outputbytes;
437437

438438
outputbytes=SendFunctionCall(&thisState->finfo,attr);
439-
pq_sendint(buf,VARSIZE(outputbytes)-VARHDRSZ,4);
439+
pq_sendint32(buf,VARSIZE(outputbytes)-VARHDRSZ);
440440
pq_sendbytes(buf,VARDATA(outputbytes),
441441
VARSIZE(outputbytes)-VARHDRSZ);
442442
}
@@ -494,13 +494,13 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self)
494494
k >>=1;
495495
if (k==0)/* end of byte? */
496496
{
497-
pq_sendint(buf,j,1);
497+
pq_sendint8(buf,j);
498498
j=0;
499499
k=1 <<7;
500500
}
501501
}
502502
if (k!= (1 <<7))/* flush last partial byte */
503-
pq_sendint(buf,j,1);
503+
pq_sendint8(buf,j);
504504

505505
/*
506506
* send the attributes of this tuple
@@ -679,13 +679,13 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
679679
k >>=1;
680680
if (k==0)/* end of byte? */
681681
{
682-
pq_sendint(buf,j,1);
682+
pq_sendint8(buf,j);
683683
j=0;
684684
k=1 <<7;
685685
}
686686
}
687687
if (k!= (1 <<7))/* flush last partial byte */
688-
pq_sendint(buf,j,1);
688+
pq_sendint8(buf,j);
689689

690690
/*
691691
* send the attributes of this tuple
@@ -702,7 +702,7 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
702702
Assert(thisState->format==1);
703703

704704
outputbytes=SendFunctionCall(&thisState->finfo,attr);
705-
pq_sendint(buf,VARSIZE(outputbytes)-VARHDRSZ,4);
705+
pq_sendint32(buf,VARSIZE(outputbytes)-VARHDRSZ);
706706
pq_sendbytes(buf,VARDATA(outputbytes),
707707
VARSIZE(outputbytes)-VARHDRSZ);
708708
}

‎src/backend/access/transam/parallel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,8 @@ ParallelWorkerMain(Datum main_arg)
10301030
* in this case.
10311031
*/
10321032
pq_beginmessage(&msgbuf,'K');
1033-
pq_sendint(&msgbuf, (int32)MyProcPid,sizeof(int32));
1034-
pq_sendint(&msgbuf, (int32)MyCancelKey,sizeof(int32));
1033+
pq_sendint32(&msgbuf, (int32)MyProcPid);
1034+
pq_sendint32(&msgbuf, (int32)MyCancelKey);
10351035
pq_endmessage(&msgbuf);
10361036

10371037
/*

‎src/backend/commands/async.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ NotifyMyFrontEnd(const char *channel, const char *payload, int32 srcPid)
21002100
StringInfoDatabuf;
21012101

21022102
pq_beginmessage(&buf,'A');
2103-
pq_sendint(&buf,srcPid,sizeof(int32));
2103+
pq_sendint32(&buf,srcPid);
21042104
pq_sendstring(&buf,channel);
21052105
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >=3)
21062106
pq_sendstring(&buf,payload);

‎src/backend/commands/copy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ SendCopyBegin(CopyState cstate)
357357

358358
pq_beginmessage(&buf,'H');
359359
pq_sendbyte(&buf,format);/* overall format */
360-
pq_sendint(&buf,natts,2);
360+
pq_sendint16(&buf,natts);
361361
for (i=0;i<natts;i++)
362-
pq_sendint(&buf,format,2);/* per-column formats */
362+
pq_sendint16(&buf,format);/* per-column formats */
363363
pq_endmessage(&buf);
364364
cstate->copy_dest=COPY_NEW_FE;
365365
}
@@ -390,9 +390,9 @@ ReceiveCopyBegin(CopyState cstate)
390390

391391
pq_beginmessage(&buf,'G');
392392
pq_sendbyte(&buf,format);/* overall format */
393-
pq_sendint(&buf,natts,2);
393+
pq_sendint16(&buf,natts);
394394
for (i=0;i<natts;i++)
395-
pq_sendint(&buf,format,2);/* per-column formats */
395+
pq_sendint16(&buf,format);/* per-column formats */
396396
pq_endmessage(&buf);
397397
cstate->copy_dest=COPY_NEW_FE;
398398
cstate->fe_msgbuf=makeStringInfo();

‎src/backend/libpq/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ sendAuthRequest(Port *port, AuthRequest areq, char *extradata, int extralen)
613613
CHECK_FOR_INTERRUPTS();
614614

615615
pq_beginmessage(&buf,'R');
616-
pq_sendint(&buf, (int32)areq,sizeof(int32));
616+
pq_sendint32(&buf, (int32)areq);
617617
if (extralen>0)
618618
pq_sendbytes(&buf,extradata,extralen);
619619

‎src/backend/replication/basebackup.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
274274
/* Send CopyOutResponse message */
275275
pq_beginmessage(&buf,'H');
276276
pq_sendbyte(&buf,0);/* overall format */
277-
pq_sendint(&buf,0,2);/* natts */
277+
pq_sendint16(&buf,0);/* natts */
278278
pq_endmessage(&buf);
279279

280280
if (ti->path==NULL)
@@ -722,7 +722,7 @@ send_int8_string(StringInfoData *buf, int64 intval)
722722
charis[32];
723723

724724
sprintf(is,INT64_FORMAT,intval);
725-
pq_sendint(buf,strlen(is),4);
725+
pq_sendint32(buf,strlen(is));
726726
pq_sendbytes(buf,is,strlen(is));
727727
}
728728

@@ -734,34 +734,34 @@ SendBackupHeader(List *tablespaces)
734734

735735
/* Construct and send the directory information */
736736
pq_beginmessage(&buf,'T');/* RowDescription */
737-
pq_sendint(&buf,3,2);/* 3 fields */
737+
pq_sendint16(&buf,3);/* 3 fields */
738738

739739
/* First field - spcoid */
740740
pq_sendstring(&buf,"spcoid");
741-
pq_sendint(&buf,0,4);/* table oid */
742-
pq_sendint(&buf,0,2);/* attnum */
743-
pq_sendint(&buf,OIDOID,4);/* type oid */
744-
pq_sendint(&buf,4,2);/* typlen */
745-
pq_sendint(&buf,0,4);/* typmod */
746-
pq_sendint(&buf,0,2);/* format code */
741+
pq_sendint32(&buf,0);/* table oid */
742+
pq_sendint16(&buf,0);/* attnum */
743+
pq_sendint32(&buf,OIDOID);/* type oid */
744+
pq_sendint16(&buf,4);/* typlen */
745+
pq_sendint32(&buf,0);/* typmod */
746+
pq_sendint16(&buf,0);/* format code */
747747

748748
/* Second field - spcpath */
749749
pq_sendstring(&buf,"spclocation");
750-
pq_sendint(&buf,0,4);
751-
pq_sendint(&buf,0,2);
752-
pq_sendint(&buf,TEXTOID,4);
753-
pq_sendint(&buf,-1,2);
754-
pq_sendint(&buf,0,4);
755-
pq_sendint(&buf,0,2);
750+
pq_sendint32(&buf,0);
751+
pq_sendint16(&buf,0);
752+
pq_sendint32(&buf,TEXTOID);
753+
pq_sendint16(&buf,-1);
754+
pq_sendint32(&buf,0);
755+
pq_sendint16(&buf,0);
756756

757757
/* Third field - size */
758758
pq_sendstring(&buf,"size");
759-
pq_sendint(&buf,0,4);
760-
pq_sendint(&buf,0,2);
761-
pq_sendint(&buf,INT8OID,4);
762-
pq_sendint(&buf,8,2);
763-
pq_sendint(&buf,0,4);
764-
pq_sendint(&buf,0,2);
759+
pq_sendint32(&buf,0);
760+
pq_sendint16(&buf,0);
761+
pq_sendint32(&buf,INT8OID);
762+
pq_sendint16(&buf,8);
763+
pq_sendint32(&buf,0);
764+
pq_sendint16(&buf,0);
765765
pq_endmessage(&buf);
766766

767767
foreach(lc,tablespaces)
@@ -770,28 +770,28 @@ SendBackupHeader(List *tablespaces)
770770

771771
/* Send one datarow message */
772772
pq_beginmessage(&buf,'D');
773-
pq_sendint(&buf,3,2);/* number of columns */
773+
pq_sendint16(&buf,3);/* number of columns */
774774
if (ti->path==NULL)
775775
{
776-
pq_sendint(&buf,-1,4);/* Length = -1 ==> NULL */
777-
pq_sendint(&buf,-1,4);
776+
pq_sendint32(&buf,-1);/* Length = -1 ==> NULL */
777+
pq_sendint32(&buf,-1);
778778
}
779779
else
780780
{
781781
Sizelen;
782782

783783
len=strlen(ti->oid);
784-
pq_sendint(&buf,len,4);
784+
pq_sendint32(&buf,len);
785785
pq_sendbytes(&buf,ti->oid,len);
786786

787787
len=strlen(ti->path);
788-
pq_sendint(&buf,len,4);
788+
pq_sendint32(&buf,len);
789789
pq_sendbytes(&buf,ti->path,len);
790790
}
791791
if (ti->size >=0)
792792
send_int8_string(&buf,ti->size /1024);
793793
else
794-
pq_sendint(&buf,-1,4);/* NULL */
794+
pq_sendint32(&buf,-1);/* NULL */
795795

796796
pq_endmessage(&buf);
797797
}
@@ -812,42 +812,42 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
812812
Sizelen;
813813

814814
pq_beginmessage(&buf,'T');/* RowDescription */
815-
pq_sendint(&buf,2,2);/* 2 fields */
815+
pq_sendint16(&buf,2);/* 2 fields */
816816

817817
/* Field headers */
818818
pq_sendstring(&buf,"recptr");
819-
pq_sendint(&buf,0,4);/* table oid */
820-
pq_sendint(&buf,0,2);/* attnum */
821-
pq_sendint(&buf,TEXTOID,4);/* type oid */
822-
pq_sendint(&buf,-1,2);
823-
pq_sendint(&buf,0,4);
824-
pq_sendint(&buf,0,2);
819+
pq_sendint32(&buf,0);/* table oid */
820+
pq_sendint16(&buf,0);/* attnum */
821+
pq_sendint32(&buf,TEXTOID);/* type oid */
822+
pq_sendint16(&buf,-1);
823+
pq_sendint32(&buf,0);
824+
pq_sendint16(&buf,0);
825825

826826
pq_sendstring(&buf,"tli");
827-
pq_sendint(&buf,0,4);/* table oid */
828-
pq_sendint(&buf,0,2);/* attnum */
827+
pq_sendint32(&buf,0);/* table oid */
828+
pq_sendint16(&buf,0);/* attnum */
829829

830830
/*
831831
* int8 may seem like a surprising data type for this, but in theory int4
832832
* would not be wide enough for this, as TimeLineID is unsigned.
833833
*/
834-
pq_sendint(&buf,INT8OID,4);/* type oid */
835-
pq_sendint(&buf,-1,2);
836-
pq_sendint(&buf,0,4);
837-
pq_sendint(&buf,0,2);
834+
pq_sendint32(&buf,INT8OID);/* type oid */
835+
pq_sendint16(&buf,-1);
836+
pq_sendint32(&buf,0);
837+
pq_sendint16(&buf,0);
838838
pq_endmessage(&buf);
839839

840840
/* Data row */
841841
pq_beginmessage(&buf,'D');
842-
pq_sendint(&buf,2,2);/* number of columns */
842+
pq_sendint16(&buf,2);/* number of columns */
843843

844844
len=snprintf(str,sizeof(str),
845845
"%X/%X", (uint32) (ptr >>32), (uint32)ptr);
846-
pq_sendint(&buf,len,4);
846+
pq_sendint32(&buf,len);
847847
pq_sendbytes(&buf,str,len);
848848

849849
len=snprintf(str,sizeof(str),"%u",tli);
850-
pq_sendint(&buf,len,4);
850+
pq_sendint32(&buf,len);
851851
pq_sendbytes(&buf,str,len);
852852

853853
pq_endmessage(&buf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp