* pqDropServerData * * Clear all connection state data that was received from (or deduced about) * the server. This is essential to do between connection attempts to * different servers, else we may incorrectly hold over some data from the * old server. * * It would be better to merge this into pqDropConnection, perhaps, but * right now we cannot because that function is called immediate
| 622 | * should be kept until we are actually starting a new connection. |
| 623 | */ |
| 624 | static void |
| 625 | pqDropServerData(PGconn *conn) |
| 626 | { |
| 627 | PGnotify *notify; |
| 628 | pgParameterStatus *pstatus; |
| 629 | |
| 630 | /* Forget pending notifies */ |
| 631 | notify = conn->notifyHead; |
| 632 | while (notify != NULL) |
| 633 | { |
| 634 | PGnotify *prev = notify; |
| 635 | |
| 636 | notify = notify->next; |
| 637 | free(prev); |
| 638 | } |
| 639 | conn->notifyHead = conn->notifyTail = NULL; |
| 640 | |
| 641 | pqFreeCommandQueue(conn->cmd_queue_head); |
| 642 | conn->cmd_queue_head = conn->cmd_queue_tail = NULL; |
| 643 | |
| 644 | pqFreeCommandQueue(conn->cmd_queue_recycle); |
| 645 | conn->cmd_queue_recycle = NULL; |
| 646 | |
| 647 | /* Reset ParameterStatus data, as well as variables deduced from it */ |
| 648 | pstatus = conn->pstatus; |
| 649 | while (pstatus != NULL) |
| 650 | { |
| 651 | pgParameterStatus *prev = pstatus; |
| 652 | |
| 653 | pstatus = pstatus->next; |
| 654 | free(prev); |
| 655 | } |
| 656 | conn->pstatus = NULL; |
| 657 | conn->client_encoding = PG_SQL_ASCII; |
| 658 | conn->std_strings = false; |
| 659 | conn->default_transaction_read_only = PG_BOOL_UNKNOWN; |
| 660 | conn->in_hot_standby = PG_BOOL_UNKNOWN; |
| 661 | conn->sversion = 0; |
| 662 | |
| 663 | /* Drop large-object lookup data */ |
| 664 | if (conn->lobjfuncs) |
| 665 | free(conn->lobjfuncs); |
| 666 | conn->lobjfuncs = NULL; |
| 667 | |
| 668 | /* Reset assorted other per-connection state */ |
| 669 | conn->last_sqlstate[0] = '\0'; |
| 670 | conn->auth_req_received = false; |
| 671 | conn->password_needed = false; |
| 672 | conn->write_failed = false; |
| 673 | if (conn->write_err_msg) |
| 674 | free(conn->write_err_msg); |
| 675 | conn->write_err_msg = NULL; |
| 676 | conn->be_pid = 0; |
| 677 | conn->be_key = 0; |
| 678 | } |
| 679 | |
| 680 | |
| 681 | /* |
no test coverage detected