Fixed counting exception (backport to 2.4 branch from master).

Fixed "Invalid parameter number: number of bound variables does not match number of tokens " exception during execution count on Query where select part of query contains :parameters.