public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jelte Fennema-Nio <[email protected]>
To: David Rowley <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Melih Mutlu <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Heikki Linnakangas <[email protected]>
Cc: Robert Haas <[email protected]>
Cc: Thomas Munro <[email protected]>
Cc: Ranier Vilela <[email protected]>
Subject: Re: Flushing large data immediately in pqcomm
Date: Mon, 8 Apr 2024 12:42:23 +0200
Message-ID: <CAGECzQRy1DBTkhKgnoFcep5JNk-eGt71Dtf_axc1ihGzXnakFQ@mail.gmail.com> (raw)
In-Reply-To: <CAApHDvrBJeqj0e+4YcudraB9inQDL-ODFvz13Oe40AcET=vbig@mail.gmail.com>
References: <CAGECzQTgup-uK9YXTM+24ib4VVk93RW_Stsh3KtHGZnrCybdyA@mail.gmail.com>
	<CAGPVpCQ-265P-DY8hZADEKE5GO0-1NVB9kn7dH82BQgEUbdv1g@mail.gmail.com>
	<CAApHDvoxAnbaxRnn=uEZow_xMK=dEqHHKksTHVRMtK4sNRt2_Q@mail.gmail.com>
	<CAGPVpCSJN5sdSB6bjGCuP5v_6=zPhTeZef_VhsRStiyHci+rLg@mail.gmail.com>
	<CAGPVpCRc1vE4reowMynubn09Y2KKuK3OdVrPySGUkgJwYmse7g@mail.gmail.com>
	<CAGECzQRbn5iq7LFhFSjywO2Aa9qQKzAGYeXH0M2M4t9edsbF7Q@mail.gmail.com>
	<CAGPVpCQWUz=VGAjycSw_1aRLRXj5wp8hubZHq992KBxp25veSQ@mail.gmail.com>
	<CAApHDvomWMAHVEUJL0bXE4Og9qwAeqdehP9gcWS6Px0yc6aH+Q@mail.gmail.com>
	<[email protected]>
	<CAGECzQRNBaGu8TrUk+oAnTSd4r1-Osb7a8R6w8FJDzBhKTpeyA@mail.gmail.com>
	<[email protected]>
	<CAGECzQQUNpu2NQB01FLEVnxPeYBY1V5eG24z11BTMz9R6J5nyQ@mail.gmail.com>
	<CAApHDvrBJeqj0e+4YcudraB9inQDL-ODFvz13Oe40AcET=vbig@mail.gmail.com>

On Sun, 7 Apr 2024 at 14:41, David Rowley <[email protected]> wrote:
> Looking at the code in socket_putmessage_noblock(), I don't understand
> why it's ok for PqSendBufferSize to be int but "required" must be
> size_t.  There's a line that does "PqSendBufferSize = required;". It
> kinda looks like they both should be size_t.  Am I missing something
> that you've thought about?


You and Ranier are totally right (I missed this assignment). Attached is v8.


Attachments:

  [application/octet-stream] v8-0001-Make-a-few-variables-size_t-in-pqcomm.c.patch (1.3K, ../CAGECzQRy1DBTkhKgnoFcep5JNk-eGt71Dtf_axc1ihGzXnakFQ@mail.gmail.com/2-v8-0001-Make-a-few-variables-size_t-in-pqcomm.c.patch)
  download | inline diff:
From def294980e01ca412f83fdfcd0b37d27726f2c0f Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <[email protected]>
Date: Mon, 8 Apr 2024 12:40:01 +0200
Subject: [PATCH v8] Make a few variables size_t in pqcomm.c

This is needed since c4ab7da6061 to avoid overflows in case int is
smaller than size_t.

Reported-By: Ranier Vilela
---
 src/backend/libpq/pqcomm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 2cee49a2085..af43eef2eee 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -119,7 +119,7 @@ static List *sock_paths = NIL;
 #define PQ_RECV_BUFFER_SIZE 8192
 
 static char *PqSendBuffer;
-static int	PqSendBufferSize;	/* Size send buffer */
+static size_t PqSendBufferSize; /* Size send buffer */
 static size_t PqSendPointer;	/* Next index to store a byte in PqSendBuffer */
 static size_t PqSendStart;		/* Next index to send a byte in PqSendBuffer */
 
@@ -1521,7 +1521,7 @@ static void
 socket_putmessage_noblock(char msgtype, const char *s, size_t len)
 {
 	int			res PG_USED_FOR_ASSERTS_ONLY;
-	int			required;
+	size_t		required;
 
 	/*
 	 * Ensure we have enough space in the output buffer for the message header

base-commit: 422041542f313f23ca66cad26e9b2b99c4d1999a
-- 
2.34.1



view thread (29+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Flushing large data immediately in pqcomm
  In-Reply-To: <CAGECzQRy1DBTkhKgnoFcep5JNk-eGt71Dtf_axc1ihGzXnakFQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox