anchor.diff:  -export([ exec/5
           , parse/1
           ]).
  +
  +-define(MaxChar,16#FFFFFF).
   
   -export([ field_qname/1
           , field_name/1
  
positive.code:                 {-A,-B,-C,-D};
              {A,B,C,D,E,F,G,H} when is_integer(A), is_integer(B), is_integer(C), is_integer(D), is_integer(E), is_integer(F), is_integer(G), is_integer(H) ->
                  {-A,-B,-C,-D,-E,-F,-G,-H};
              _ ->
                  element(Ci,element(Ti,X))
          end
  
negative.code: sort_spec_order([],_,_,Acc) -> 
      lists:reverse(Acc);        
  sort_spec_order([SS|SortSpecs],FullMaps,ColMaps, Acc) ->
      sort_spec_order(SortSpecs,FullMaps,ColMaps,[sort_order(SS,FullMaps,ColMaps)|Acc]).
  
  sort_order({Ti,Ci,Direction},FullMaps,_) ->
      %% SortSpec given referencing FullMap Ti,Ci    
      case [{S,T,N} || #ddColMap{tind=Tind,cind=Cind,schema=S,table=T,name=N} <- FullMaps, Tind==Ti, Cind==Ci] of
          [QN] -> {list_to_binary(field_name(QN)),Direction};
          _ ->    ?ClientError({"Bad sort field reference", {Ti,Ci}})
      end;
  sort_order({Cp,Direction},_,ColMaps) when is_integer(Cp) ->
      %% SortSpec given referencing ColMap position    
      #ddColMap{schema=S,table=T,name=N} = lists:nth(Cp,ColMaps),
      {list_to_binary(field_name({S,T,N})),Direction};
  sort_order({CName,Direction},FullMaps,_) ->
      %% SortSpec given referencing FullMap alias    
      case lists:keysearch(CName, #ddColMap.alias, FullMaps) of
          #ddColMap{schema=S,table=T,name=N} ->
              {list_to_binary(field_name({S,T,N})),Direction};
          _ -> 
              ?ClientError({"Bad sort field name", CName})
      end.
  