MCPcopy Create free account
hub / github.com/apache/cloudberry / ProcessResult

Function ProcessResult

src/bin/psql/common.c:909–1074  ·  view source on GitHub ↗

* ProcessResult: utility function for use by SendQuery() only * * When our command string contained a COPY FROM STDIN or COPY TO STDOUT, * PQexec() has stopped at the PGresult associated with the first such * command. In that event, we'll marshal data for the COPY and then cycle * through any subsequent PGresult objects. * * When the command string contained no such COPY command, this func

Source from the content-addressed store, hash-verified

907 * server-side opinion.
908 */
909static bool
910ProcessResult(PGresult **results)
911{
912 bool success = true;
913 bool first_cycle = true;
914
915 for (;;)
916 {
917 ExecStatusType result_status;
918 bool is_copy;
919 PGresult *next_result;
920
921 if (!AcceptResult(*results))
922 {
923 /*
924 * Failure at this point is always a server-side failure or a
925 * failure to submit the command string. Either way, we're
926 * finished with this command string.
927 */
928 success = false;
929 break;
930 }
931
932 result_status = PQresultStatus(*results);
933 switch (result_status)
934 {
935 case PGRES_EMPTY_QUERY:
936 case PGRES_COMMAND_OK:
937 case PGRES_TUPLES_OK:
938 is_copy = false;
939 break;
940
941 case PGRES_COPY_OUT:
942 case PGRES_COPY_IN:
943 is_copy = true;
944 break;
945
946 default:
947 /* AcceptResult() should have caught anything else. */
948 is_copy = false;
949 pg_log_error("unexpected PQresultStatus: %d", result_status);
950 break;
951 }
952
953 if (is_copy)
954 {
955 /*
956 * Marshal the COPY data. Either subroutine will get the
957 * connection out of its COPY state, then call PQresultStatus()
958 * once and report any error.
959 *
960 * For COPY OUT, direct the output to pset.copyStream if it's set,
961 * otherwise to pset.gfname if it's set, otherwise to queryFout.
962 * For COPY IN, use pset.copyStream as data source if it's set,
963 * otherwise cur_cmd_source.
964 */
965 FILE *copystream;
966 PGresult *copy_result;

Callers 1

SendQueryFunction · 0.85

Calls 14

AcceptResultFunction · 0.85
PQresultStatusFunction · 0.85
SetCancelConnFunction · 0.85
openQueryOutputFileFunction · 0.85
disable_sigpipe_trapFunction · 0.85
handleCopyOutFunction · 0.85
PQclearFunction · 0.85
restore_sigpipe_trapFunction · 0.85
handleCopyInFunction · 0.85
PQbinaryTuplesFunction · 0.85
ResetCancelConnFunction · 0.85
PQgetResultFunction · 0.85

Tested by

no test coverage detected