Skip to content

Commit

Permalink
Merge 7f329f2 into fd6f0f9
Browse files Browse the repository at this point in the history
  • Loading branch information
iAchilles committed Oct 14, 2016
2 parents fd6f0f9 + 7f329f2 commit 6cf8747
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/ejabberd_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -806,29 +806,43 @@ pgsql_to_odbc({ok, PGSQLResult}) ->
end.

pgsql_item_to_odbc({<<"SELECT", _/binary>>, Rows,
Recs}) ->
{selected, [element(1, Row) || Row <- Rows], Recs};
Recs}) ->
{selected, [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc({<<"FETCH", _/binary>>, Rows,
Recs}) ->
{selected, [element(1, Row) || Row <- Rows], Recs};
Recs}) ->
{selected, [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc(<<"INSERT ", OIDN/binary>>) ->
[_OID, N] = str:tokens(OIDN, <<" ">>),
{updated, jlib:binary_to_integer(N)};
[_OID, N] = str:tokens(OIDN, <<" ">>),
{updated, jlib:binary_to_integer(N)};
pgsql_item_to_odbc({<<"INSERT ", OIDN/binary>>, Rows, Recs}) ->
[_OID, N] = str:tokens(OIDN, <<" ">>),
{updated, jlib:binary_to_integer(N), [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc(<<"DELETE ", N/binary>>) ->
{updated, jlib:binary_to_integer(N)};
{updated, jlib:binary_to_integer(N)};
pgsql_item_to_odbc({<<"DELETE ", N/binary>>, Rows, Recs}) ->
{updated, jlib:binary_to_integer(N), [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc(<<"UPDATE ", N/binary>>) ->
{updated, jlib:binary_to_integer(N)};
{updated, jlib:binary_to_integer(N)};
pgsql_item_to_odbc({<<"UPDATE ", N/binary>>, Rows, Recs}) ->
{updated, jlib:binary_to_integer(N), [element(1, Row) || Row <- Rows], Recs};
pgsql_item_to_odbc({error, Error}) -> {error, Error};
pgsql_item_to_odbc(_) -> {updated, undefined}.

pgsql_execute_to_odbc({ok, {<<"SELECT", _/binary>>, Rows}}) ->
{selected, [], [[Field || {_, Field} <- Row] || Row <- Rows]};
{selected, [], [[Field || {_, Field} <- Row] || Row <- Rows]};
pgsql_execute_to_odbc({ok, {'INSERT', N}}) ->
{updated, N};
{updated, N};
pgsql_execute_to_odbc({ok, {<<"INSERT ", OIDN/binary>>, Rows}}) ->
[_OID, N] = str:tokens(OIDN, <<" ">>),
{updated, jlib:binary_to_integer(N), [[Field || {_, Field} <- Row] || Row <- Rows]};
pgsql_execute_to_odbc({ok, {'DELETE', N}}) ->
{updated, N};
{updated, N};
pgsql_execute_to_odbc({ok, {<<"DELETE ", N/binary>>, Rows}}) ->
{updated, jlib:binary_to_integer(N), [[Field || {_, Field} <- Row] || Row <- Rows]};
pgsql_execute_to_odbc({ok, {'UPDATE', N}}) ->
{updated, N};
{updated, N};
pgsql_execute_to_odbc({ok, {<<"UPDATE ", N/binary>>, Rows}}) ->
{updated, jlib:binary_to_integer(N), [[Field || {_, Field} <- Row] || Row <- Rows]};
pgsql_execute_to_odbc({error, Error}) -> {error, Error};
pgsql_execute_to_odbc(_) -> {updated, undefined}.

Expand Down

0 comments on commit 6cf8747

Please sign in to comment.