  In 1922 Ritt constructed the theory of functional decompositions of
polynomials with complex coefficients. In particular, he described explicitly
indecomposable polynomial solutions of the functional equation f(p(z))=g(q(z)).
In this paper we study the equation above in the case when f,g,p,q are
holomorphic functions on compact Riemann surfaces. We also construct a
self-contained theory of functional decompositions of rational functions with
at most two poles generalizing the Ritt theory. In particular, we give new
proofs of the theorems of Ritt and of the theorem of Bilu and Tichy.
