* Consume any available input from the backend * 0 return: some kind of trouble * 1 return: no problem */
| 1936 | * 1 return: no problem |
| 1937 | */ |
| 1938 | int |
| 1939 | PQconsumeInput(PGconn *conn) |
| 1940 | { |
| 1941 | if (!conn) |
| 1942 | return 0; |
| 1943 | |
| 1944 | /* |
| 1945 | * for non-blocking connections try to flush the send-queue, otherwise we |
| 1946 | * may never get a response for something that may not have already been |
| 1947 | * sent because it's in our write buffer! |
| 1948 | */ |
| 1949 | if (pqIsnonblocking(conn)) |
| 1950 | { |
| 1951 | if (pqFlush(conn) < 0) |
| 1952 | return 0; |
| 1953 | } |
| 1954 | |
| 1955 | /* |
| 1956 | * Load more data, if available. We do this no matter what state we are |
| 1957 | * in, since we are probably getting called because the application wants |
| 1958 | * to get rid of a read-select condition. Note that we will NOT block |
| 1959 | * waiting for more input. |
| 1960 | */ |
| 1961 | if (pqReadData(conn) < 0) |
| 1962 | return 0; |
| 1963 | |
| 1964 | /* Parsing of the data waits till later. */ |
| 1965 | return 1; |
| 1966 | } |
| 1967 | |
| 1968 | |
| 1969 | /* |