Closed charankamarapu closed 9 months ago
Out of interest, why are you asking?
I wanted to learn how database client and server works. Oracle is one of the complex database, so I thought I would start with oracle. I was going through the code from long time and really stuck at this point that how will the server know when client sends multiple data packets, needed some help here.
Usually the header (packet) contains the overall size value client is about to send to the server.
Yes but here I guess that is not the case. The header contains only the packet size that is sent not the overall size. Once execution goes to _write_more_data it passes down to send_packet function and Packet header is added with the size of the packet at that moment and sent to server.
Each packet that is sent has a length. The client or server (whoever is receiving that packet) reads just that many bytes. It then begins the process of decoding the client/server response. If the client/server response is not complete by the time the end of the packet has been reached it waits for another packet and continues the process once that data is received. In 23c a flag is being added that will indicate when the client/server response is complete. This flag will be set on the last packet that contains the client/server response. This is not yet available, however, so for now the client/server must read through as many packets as required until the end of the response is known (by mutual understanding of what the response contains). If something goes wrong during this process a break/reset mechanism is employed so that both client and server can know where the other is at. I hope that answers your questions!
Thank you so much, @anthony-tuininga! Your explanation was clear 😃 .
I was going through the code and came across two functions
I have understood that we use _write_more_data for sending a packet but we know that is not the final packet from client side and next packets will be data packet , we use end_request for sending packet but we know that it is the last packet.
But I have a question - how will the server know that it needs to wait for next packet without parsing complete current packet in the case of _write_more_data because we didn't send any identification flag in the first packet saying that it is not the final packet .
Can someone please answer this query..?