backsql_val_escape( Operation *op, struct berval *in, struct berval *out )
{
	char *ptr, *end;
	int q = 0;

	ptr = in->bv_val;
	end = ptr + in->bv_len;
	while (ptr < end) {
		if ( *ptr == '\'' )
			q++;
		ptr++;
	}
	if ( q && out ) {
		char *dst;
		out->bv_len = in->bv_len + q;
		out->bv_val = op->o_tmpalloc( out->bv_len + 1, op->o_tmpmemctx );
		ptr = in->bv_val;
		dst = out->bv_val;
		while (ptr < end ) {
			if ( *ptr == '\'' )
				*dst++ = '\'';
			*dst++ = *ptr++;
		}
		*dst = '\0';
	}
	return q;
}
backsql_val_escape( Operation *op, struct berval *in, struct berval *out )
{
	char *ptr, *end;
	int q = 0;

	ptr = in->bv_val;
	end = ptr + in->bv_len;
	while (ptr < end) {
		if ( *ptr == '\'' )
			q++;
		ptr++;
	}
	if ( q && out ) {
		char *dst;
		out->bv_len = in->bv_len + q;
		out->bv_val = op->o_tmpalloc( out->bv_len + 1, op->o_tmpmemctx );
		ptr = in->bv_val;
		dst = out->bv_val;
		while (ptr < end ) {
			if ( *ptr == '\'' )
				*dst++ = '\'';
			*dst++ = *ptr++;
		}
		*dst = '\0';
	}
	return q;
}