I am mounting shelves using plastic anchors in masonry. I once saw a contractor use an adhesive on the anchors to prevent them from pulling out. I realize that by design this should not be necessary. But, if one wanted a little better strength to ensure the anchor would not pull out, what adhesive would be used?
Anchors are not intended for resisting longitudinal loads ('pulling'); they are meant for resisting sheer loads. If your shelves will pull on the anchors, redesign the shelves--you are setting yourself up for failure.
If you do want to resist pulling, use the 'bent nail' type of fastener, or a masonry screw. The blue Tapcon anchor screws work quite well into concrete blocks; the other kind, which you hammer into place, work great into solid (non-porous) concrete.
In your situation I would use a few screws to fasten a rail of wood to the masonry, and then attach the shelves to that.
You could try some "No Nails" or equivalent, though as you say it shouldn't be necessary.
The size of screw you are using will determine the size of the anchor you use. This in turn will determine the size of hole you drill.
The anchor should fit snugly into the hole and even require a light tap with a small hammer to ensure it fits flush with the surface. This will mean that the grippers on the sides will have a good purchase on the brickwork as you drive the screw home. It's this outwards force that will stop the anchor coming out of the hole.