| 2869 | */ |
| 2870 | |
| 2871 | PGresult * |
| 2872 | PQfn(PGconn *conn, |
| 2873 | int fnid, |
| 2874 | int *result_buf, |
| 2875 | int *result_len, |
| 2876 | int result_is_int, |
| 2877 | const PQArgBlock *args, |
| 2878 | int nargs) |
| 2879 | { |
| 2880 | *result_len = 0; |
| 2881 | |
| 2882 | if (!conn) |
| 2883 | return NULL; |
| 2884 | |
| 2885 | /* |
| 2886 | * Since this is the beginning of a query cycle, reset the error buffer. |
| 2887 | */ |
| 2888 | resetPQExpBuffer(&conn->errorMessage); |
| 2889 | |
| 2890 | if (conn->pipelineStatus != PQ_PIPELINE_OFF) |
| 2891 | { |
| 2892 | appendPQExpBufferStr(&conn->errorMessage, |
| 2893 | libpq_gettext("PQfn not allowed in pipeline mode\n")); |
| 2894 | return NULL; |
| 2895 | } |
| 2896 | |
| 2897 | if (conn->sock == PGINVALID_SOCKET || conn->asyncStatus != PGASYNC_IDLE || |
| 2898 | conn->result != NULL) |
| 2899 | { |
| 2900 | appendPQExpBufferStr(&conn->errorMessage, |
| 2901 | libpq_gettext("connection in wrong state\n")); |
| 2902 | return NULL; |
| 2903 | } |
| 2904 | |
| 2905 | return pqFunctionCall3(conn, fnid, |
| 2906 | result_buf, result_len, |
| 2907 | result_is_int, |
| 2908 | args, nargs); |
| 2909 | } |
| 2910 | |
| 2911 | /* ====== Pipeline mode support ======== */ |
| 2912 | |