Do smth like along the lines (might want to add additional code for ordering, this just happens to run correctly) :
select * from my_table where cat = 500 UNION select null,null LIMIT CASE WHEN (select count(*) from my_table where cat=500)>0 THEN (select count(*) from my_table where cat=500) ELSE 1 END ; Of course you can write a function to do that for you, but what made you want this in the first place? Maybe this is bad design ?
Unfortunately this is a constraint of the environment; not good design, but SQL seems like it should be the simplest place to solve this.
I tried your example; it seems the ordering is required, otherwise the results always include the null. So the below works for anyone who finds this in the future. Thanks
select id from my_table where cat = 2
UNION
select null as id ORDER BY id ASC LIMIT CASE WHEN ( select count(*) from my_table where cat = 2 ) > 0 THEN ( select count(*) from my_table where cat=2 ) ELSE 1 END;