/*
 * call-seq:
 *    conn.cancel() -> String
 *
 * Requests cancellation of the command currently being
 * processed.
 *
 * Returns +nil+ on success, or a string containing the
 * error message if a failure occurs.
 */
static VALUE
pgconn_cancel(VALUE self)
{
    char errbuf[256];
    PGcancel *cancel;
    VALUE retval;
    int ret;

    cancel = PQgetCancel(get_pgconn(self));
    if(cancel == NULL)
        rb_raise(rb_ePGError,"Invalid connection!");

    ret = PQcancel(cancel, errbuf, 256);
    if(ret == 1) 
        retval = Qnil;
    else
        retval = rb_str_new2(errbuf);

    PQfreeCancel(cancel);
    return retval;
}