/*
 * Returns a SQL-safe version of the String _str_. Unlike #quote, does not wrap the String in '...'.
 */
static VALUE
pgconn_s_escape(self, string)
    VALUE self;
    VALUE string;
{
    char *escaped;
    int size;
    VALUE result;

    Check_Type(string, T_STRING);
    
    escaped = ALLOCA_N(char, RSTRING_LEN(string) * 2 + 1);
    size = PQescapeString(escaped, RSTRING_PTR(string), RSTRING_LEN(string));
    result = rb_str_new(escaped, size);
    OBJ_INFECT(result, string);
    return result;
}