River/Riverbank
If waterway='river' is within waterway='riverbank', don't move arrow and text.
http://gis.stackexchange.com/questions/56874/how-to-split-line-layer-at-polygons-boundary-of-a-polygon-layer
This selects all line segments that intersect with riverbank polygons:
SELECT l.way,l.name,l.waterway FROM planet_osm_line l JOIN planet_osm_polygon p ON ST_Intersects(p.way,l.way) WHERE p.waterway='riverbank' AND l.name='Wiesent' AND l.waterway='river'
Problem: We need to cut the line into multiple lines at the border of the polygon.
Here is a example: The river without riverbank polygon, label gets moved to one side:
A river with riverbank, label should not be moved to one side, but stay in the center, not like this:

select st_dump(st_split((select way FROM planet_osm_line where osm_id=23690734),(select st_union(way) from planet_osm_polygon where waterway='riverbank' and ST_Intersects(way,(select way FROM planet_osm_line where osm_id=23690734)))));
returns 3 parts of way 23690734, but without info, which of them are inside a riverbank or outside. Maybe one could write a view/function which returns all parts with all tags and an additional flag "is_insideriverbank".
Just as a proof of concept: you could use something like this funktion to get these parts of the Wiesent: 
But
- It's far too slow for being done while rendering
- If you want to do it in some kind of preprocessing its also slow and you will get problems when updating the database. For each river in the osm database there are 1-N river parts related to this id (N=9 for way 263200527). You have to create them all, when the river is updated. Either you have to know which river was updated or you have to update all rivers from time to time...
@max-dn Could ST_Subdevide be a good a solution? http://www.stevencanplan.com/2017/12/the-genius-of-using-st_subdivide-to-speed-up-postgis-intersection-comparisons/
Could ST_Subdevide be a good a solution?
Don't think so... st_subdevide is useful for large areas with complicated shape. waterway=riverbank in osm are small areas with simple lines: 70% have less than 100 Nodes, 92% less than 200, only 1% has more than 1000 (not necessary the largest, this one is mapped with 8527 nodes). Dividing this simple polygons in more simple won't help. In the manual for ST_Subdevide there is a reference to ST_Segmentize. Maybe splitting the waterway in short ways (short but long enough for a label..) could work....