       lo_close(conn, lo_fd);       close(fd);        res = PQexec(conn, "END");       PQclear(res);        res = PQexec(conn, "BEGIN");       PQclear(res);        fd = open(FILE_TO_EXPORT, O_CREATE | O_WRONLY, 0000);       if (fd < 0)       {         fprintf(stderr, "open: failed to open file %s\n", FILE_TO_EXPORT);         return 0;       }        lo_fd = lo_open(conn, lo_oid, INV_