aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2013-01-17 11:18:11 +0100
committerFredrik Gustafsson <[email protected]>2013-03-27 16:47:53 +0100
commita8ca64098870e420f9f28f1d70433f45dc4ba3f9 (patch)
treec3774af9da4853841eea8caa0088bf4faf224525
parent16ea8d79a1df685acf92d338d6843144b6a85d1d (diff)
downloadotp-a8ca64098870e420f9f28f1d70433f45dc4ba3f9.tar.gz
otp-a8ca64098870e420f9f28f1d70433f45dc4ba3f9.tar.bz2
otp-a8ca64098870e420f9f28f1d70433f45dc4ba3f9.zip
explain postgres pecularity for param query out parameters
-rw-r--r--lib/odbc/test/oracle.erl1
-rw-r--r--lib/odbc/test/postgres.erl25
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/odbc/test/oracle.erl b/lib/odbc/test/oracle.erl
index 052461ba4f..95cf7155dc 100644
--- a/lib/odbc/test/oracle.erl
+++ b/lib/odbc/test/oracle.erl
@@ -241,6 +241,7 @@ describe_floating() ->
describe_dec_num() ->
{ok,[{"MYDEC",{sql_decimal,9,3}},{"MYNUM",{sql_decimal,9,2}}]}.
+%-------------------------------------------------------------------------
drop_proc() ->
"drop procedure test_proc1;".
diff --git a/lib/odbc/test/postgres.erl b/lib/odbc/test/postgres.erl
index 811d5ebaed..0c1761b835 100644
--- a/lib/odbc/test/postgres.erl
+++ b/lib/odbc/test/postgres.erl
@@ -294,6 +294,7 @@ describe_dec_num() ->
describe_timestamp() ->
{ok, [{"field", sql_timestamp}]}.
+%-------------------------------------------------------------------------
drop_proc() ->
"drop function test_proc1(OUT integer, OUT integer);".
@@ -308,10 +309,26 @@ stored_proc_integer_out() ->
"END " ++
"$$ LANGUAGE plpgsql ".
+%% This does not test what you might think it is supposed to test.
+%% Since the stored procedure has got 2 out parameters and no
+%% in parameters it is of arity 0 as called below.
+%%
+%% The port program odbcserver.c will marshal these out parameters
+%% and hand them to ODBC. The ODBC driver for postgres will
+%% apparently not give a hoot about these out parameters and instead
+%% return the result in a regular result select set. The port program
+%% will assume it has the result in the out parameters and marshal
+%% these as they are i.e as it itself had packed them, so they
+%% come back unchanged.
+%%
+%% The real function result goes into the void but the code in odbcserver.c
+%% that marshals out parameters returned from ODBC will be run
+%% so that is what this test tests...
+%%
param_query(Ref) ->
- odbc:param_query(Ref, "select * from test_proc1(?, ?)",
- [{sql_integer, out, [123]},
- {sql_integer, out, [456]}]).
+ odbc:param_query(Ref, "select * from test_proc1()",
+ [{sql_integer, out, [111]},
+ {sql_integer, out, [444]}]).
query_result() ->
- {executed, 2, [{123, 456}]}.
+ {executed, 2, [{111, 444}]}.