In the setup in the question, it should really say "we could have invertible meromorphic functions on Spec($A$) that don't come Frac($A)^{\times}$", since those are what give rise to "extra principal Cartier divisors". This is what I will prove cannot happen. The argument is a correction on an earlier attempt which had a bone-headed error. [Kleiman's construction from Georges' answer is not invertible, so no inconsistency. Kleiman makes some unfortunate typos -- his $\oplus k(Q)$ should be $\prod k(Q)$, and more seriously the $t$ at the end of his construction should be $\tau$, for example -- but not a big nuisance.]
For anyone curious about general background on meromorphic functions on arbitrary schemes, see EGA IV$_4$, sec. 20, esp. 20.1.3, 20.1.4. (There is a little subtle error: in (20.1.3), $\Gamma(U,\mathcal{S})$ should consist of locally regular sections of $O_X$; this is the issue in the Kleiman reference mentioned by Georges. The content of EGA works just fine upon making that little correction. There are more hilarious errors elsewhere in IV$_4$, all correctable, such as fractions with infinite numerator and denominator, but that's a story for another day.) Also, 20.2.12 there is the result cited from Qing Liu's book in the setup for the question.
The first step in the proof is the observation that for any scheme $X$, the ring $M(X)$ of meromorphic functions is naturally identified with the direct limit of the modules Hom($J, O_X)$ as $J$ varies through quasi-coherent ideals which contain a regular section of $O_X$ Zariski-locally on $X$. Basically, such $J$ are precisely the quasi-coherent "ideals of denominators" of global meromorphic functions. This description of $M(X)$ is left to the reader as an exercise, or see section 2 of the paper "Moishezon spaces in rigid-analytic geometry" on my webpage for the solution, given there in the rigid-analytic case but by methods which are perfectly general.
Now working on Spec($A$), a global meromorphic function "is" an $A$-linear map $f:J \rightarrow A$ for an ideal $J$ that contains a non-zero-divisor Zariski-locally on $A$.
Assume $f$ is an invertible meromorphic function: there are finitely many $s_i \in J$ and a finite open cover {$U_i$} of Spec($A$) (yes, same index set) so that $s_i$ and $f(s_i)$ are non-zero-divisors on $U_i$; we may and do assume each $U_i$ is quasi-compact. Let $S$ be the non-zero-divisors in $A$. Hypotheses are preserved by $S$-localizing, and it suffices to solve after such localization (exercise). So without loss of generality each element of $A$ is either a zero-divisor or a unit. If $J=A$ then $f(x)=ax$ for some $a \in A$, so $a s_i=f(s_i)$ on each $U_i$, so all $a|_{U_i}$ are regular, so $a$ is not a zero-divisor in $A$, so $a$ is a unit in $A$ (due to the special properties we have arranged for $A$). Hence, it suffices to show $J=A$.
Since the zero scheme $V({\rm{Ann}}(s_i))$ is disjoint from $U_i$ (as $s_i|_ {U_i}$ is a regular section), the closed sets $V({\rm{Ann}}(s_i))$ and $V({\rm{Ann}}(s_2))$ have
intersection disjoint from $U_1 \cup U_2$. In other words, the quasi-coherent ideals ${\rm{Ann}}(s_1)$ and ${\rm{Ann}}(s_2)$ generate the unit ideal over $U_1 \cup U_2$.
A quasi-coherent sheaf is generated by global sections over any quasi-affine scheme, such as $U_1 \cup U_2$ (a quasi-compact open in an affine scheme), so we get $a_1 \in {\rm{Ann}}(s_1)$ and $a_2 \in {\rm{Ann}}(s_2)$ such that $a_1 + a_2 = 1$ on $U_1 \cup U_2$. Multiplying both sides by $s_1 s_2$, we get that $s_1 s_2 = 0$ on $U_1 \cup U_2$. But
$s_1$ is a regular section over $U_1$, so $s_2|_ {U_1} = 0$. But $s_2|_ {U_2}$ is a regular section, so we conclude that $U_1$ and $U_2$ are disjoint. This argument shows that the $U_i$ are pairwise disjoint.
Thus, {$U_i$} is a finite disjoint open cover of Spec($A$), so in fact each $U_i = {\rm{Spec}}(A_i)$ with $A = \prod A_i$. But recall that in $A$ every non-unit is a zero-divisor. It follows that the same holds for each $A_i$ (by inserting 1's in the other factor rings), so each regular section $s_i|_ {U_i} \in A_i$ is a unit. But the preceding argument likewise shows that $s_i|_ {U_j} = 0$ in $A_j$ for $j \ne i$, so each $s_i \in A$ has a unit component along the $i$th factor and vanishing component along the other factors. Hence, the $s_i$ generate 1, so $J = A$. QED
Edit (11/12/12): I added an explanation of the phrase "this is essentially equivalent to $X$ being $S_2$" at the end to answer aglearner's question in the comments.
[See also here and here]
Dear Jesus,
I think there are several problems with your question/desire to define a canonical divisor on any algebraic variety.
First of all, what is any algebraic variety? Perhaps you mean a quasi-projective variety (=reduced and of finite type) defined over some (algebraically closed) field.
OK, let's assume that $X$ is such a variety. Then what is a divisor on $X$? Of course, you could just say it is a formal linear combination of prime divisors, where a prime divisor is just a codimension 1 irreducible subvariety.
OK, but what if $X$ is not equidimensional? Well, let's assume it is, or even that it is irreducible.
Still, if you want to talk about divisors, you would surely want to say when two divisors are linearly equivalent. OK, we know what that is, $D_1$ and $D_2$ are linearly equivalent iff $D_1-D_2$ is a principal divisor.
But, what is a principal divisor? Here it starts to become clear why one usually assumes that $X$ is normal even to just talk about divisors, let alone defining the canonical divisor. In order to define principal divisors, one would need to define something like the order of vanishing of a regular function along a prime divisor. It's not obvious how to define this unless the local ring of the general point of any prime divisor is a DVR. Well, then this leads to one to want to assume that $X$ is $R_1$, that is, regular in codimension $1$ which is equivalent to those local rings being DVRs.
OK, now once we have this we might also want another property: If $f$ is a regular function, we would expect, that the zero set of $f$ should be 1-codimensional in $X$. In other words, we would expect that if $Z\subset X$ is a closed subset of codimension at least $2$, then if $f$ is nowhere zero on $X\setminus Z$, then it is nowhere zero on $X$. In (yet) other words, if $1/f$ is a regular function on $X\setminus Z$, then we expect that it is a regular function on $X$. This in the language of sheaves means that we expect that the push-forward of $\mathscr O_{X\setminus Z}$ to $X$ is isomorphic to $\mathscr O_X$. Now this is essentially equivalent to $X$ being $S_2$.
So we get that in order to define divisors as we are used to them, we would need that $X$ be $R_1$ and $S_2$, that is, normal.
Now, actually, one can work with objects that behave very much like divisors even on non-normal varieties/schemes, but one has to be very careful what properties work for them.
As far as I can tell, the best way is to work with Weil divisorial sheaves which are really reflexive sheaves of rank $1$. On a normal variety, the sheaf associated to a Weil divisor $D$, usually denoted by $\mathcal O_X(D)$, is indeed a reflexive sheaf of rank $1$, and conversely every reflexive sheaf of rank $1$ on a normal variety is the sheaf associated to a Weil divisor (in particular a reflexive sheaf of rank $1$ on a regular variety is an invertible sheaf) so this is indeed a direct generalization. One word of caution here: $\mathcal O_X(D)$ may be defined for Weil divisors that are not Cartier, but then this is (obviously) not an invertible sheaf.
Finally, to answer your original question about canonical divisors. Indeed it is possible to define a canonical divisor (=Weil divisorial sheaf) for all quasi-projective varieties. If $X\subseteq \mathbb P^N$ and $\overline X$ denotes the closure of $X$ in $\mathbb P^N$, then the dualizing complex of $\overline X$ is
$$
\omega_{\overline X}^\bullet=R{\mathscr H}om_{\mathbb P^N}(\mathscr O_{\overline X}, \omega_{\mathbb P^N}[N])
$$
and the canonical sheaf of $X$ is
$$
\omega_X=h^{-n}(\omega_{\overline X}^\bullet)|_X=\mathscr Ext^{N-n}_{\mathbb P^N}(\mathscr O_{\overline X},\omega_{\mathbb P^N})|_X
$$
where $n=\dim X$. (Notice that you may disregard the derived category stuff and the dualizing complex, and just make the definition using $\mathscr Ext$.) Notice further, that
if $X$ is normal, this is the same as the one you are used to and otherwise it is a reflexive sheaf of rank $1$.
As for your formula, I am not entirely sure what you mean by "where the $D_i$ are representatives of all divisors in the Class Group". For toric varieties this can be made sense as in Josh's answer, but otherwise I am not sure what you had in mind.
(Added on 11/12/12):
Lemma A scheme $X$ is $S_2$ if and only if for any $\iota:Z\to X$ closed subset of codimension at least $2$, the natural
map $\mathscr O_X\to \iota_*\mathscr O_{X\setminus Z}$ is an isomorphism.
Proof
Since both statements are local we may assume that $X$ is affine.
Let $x\in X$ be a point and $Z\subseteq X$ its closure in $X$. If $x$ is a codimension at most $1$ point, there is nothing to prove, so we may assume that $Z$ is of codimension at least $2$.
Considering the exact sequence (recall that $X$ is affine):
$$
0\to H^0_Z(X,\mathscr O_X) \to H^0(X,\mathscr O_X) \to H^0(X\setminus Z,\mathscr O_X) \to H^1_Z(X,\mathscr O_X) \to 0
$$
shows that $\mathscr O_X\to \iota_*\mathscr O_{X\setminus Z}$ is an isomorphism
if and only if
$H^0_Z(X,\mathscr O_X)=H^1_Z(X,\mathscr O_X)=0$ the latter condition is equivalent to
$$
\mathrm{depth}\mathscr O_{X,x}\geq 2,
$$
which given the assumption on the codimension is exactly the condition that $X$ is $S_2$ at $x\in X$. $\qquad\square$
Best Answer
If you want to pull back a Cartier divisor $D$, you can do that provided the image of $f$ is not contained in the support of $D$: just pull back the local equations for $D$.
If this does not happen, on an integral scheme, you can just pass to the associated line bundle $\mathcal{O}_X(D)$ and pull back that, obtaining $f^{*} \mathcal{O}_X(D)$; of course you lose some information because a line bundle determines a Cartier divisor only up to linear equivalence.
Fulton invented a nice way to avoid this distinction. Define a pseudodivisor on $X$ to be a triple $(Z, L, s)$ where $Z$ is a closed subset of $X$, $L$ a line bundle and $s$ a nowhere vanishing section on $X \setminus Z$, hence a trivialization on that open set. Then you can simply define the pullback of this triple as $(f^{-1}(Z), f^{*} L, f^{*} s)$, so you can always pull back pseudo divisors, whatever $f$ is.
The relation with Cartier divisors is the following: to a Cartier divisor $D$ you can associate a pseudodivisor $(|D|, \mathcal{O}_X(D), s)$, where $s$ is the section of $\mathcal{O}_X(D)$ which gives a local equation for $D$.
This correspondence is not bijective. First, a pseudodivisor $(Z, L, s)$ determines a Cartier divisor if $Z \subsetneq X$; note that in this case enlarging $Z$ will not change the associated Cartier divisor, so to obtain a bijective correspondence with Cartier divisors you have to factor out pseudodivisors by an equivalence relation, which I leave to you to formulate. But if $Z = X$, you only obtain a line bundle on $X$, and you have no way to get back a Cartier divisor.
If you want to know more about this, read the second chapter of Fulton's intersection theory.