aboutsummaryrefslogtreecommitdiffstats
path: root/lib/odbc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/odbc')
-rw-r--r--lib/odbc/c_src/odbcserver.c2
-rw-r--r--lib/odbc/doc/src/odbc_app_arc.ps284
-rw-r--r--lib/odbc/test/odbc_query_SUITE.erl22
-rw-r--r--lib/odbc/test/oracle.erl27
-rw-r--r--lib/odbc/test/postgres.erl39
5 files changed, 88 insertions, 286 deletions
diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index a6b3de6e48..5730e20774 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -1222,7 +1222,7 @@ static db_result_msg encode_out_params(db_state *state,
(column.type.strlen_or_indptr_array[j]));
break;
case SQL_C_SLONG:
- ei_x_encode_long(&dynamic_buffer(state), ((long*)values)[j]);
+ ei_x_encode_long(&dynamic_buffer(state), ((SQLINTEGER*)values)[j]);
break;
case SQL_C_DOUBLE:
ei_x_encode_double(&dynamic_buffer(state),
diff --git a/lib/odbc/doc/src/odbc_app_arc.ps b/lib/odbc/doc/src/odbc_app_arc.ps
deleted file mode 100644
index 1ae8bd9649..0000000000
--- a/lib/odbc/doc/src/odbc_app_arc.ps
+++ /dev/null
@@ -1,284 +0,0 @@
-%!PS-Adobe-2.0
-%%Title: odbc_app_arc.fig
-%%Creator: fig2dev Version 3.1 Patchlevel 2
-%%CreationDate: Thu Jan 8 11:11:36 2004
-%%For: ingela@gildor (Ingela Anderton, UAB/KH/P)
-%Magnification: 1.00
-%%Orientation: Landscape
-%%BoundingBox: 116 230 497 562
-%%Pages: 1
-%%BeginSetup
-%%IncludeFeature: *PageSize Letter
-%%EndSetup
-%%EndComments
-/$F2psDict 200 dict def
-$F2psDict begin
-$F2psDict /mtrx matrix put
-/col-1 {0 setgray} bind def
-/col0 {0.000 0.000 0.000 srgb} bind def
-/col1 {0.000 0.000 1.000 srgb} bind def
-/col2 {0.000 1.000 0.000 srgb} bind def
-/col3 {0.000 1.000 1.000 srgb} bind def
-/col4 {1.000 0.000 0.000 srgb} bind def
-/col5 {1.000 0.000 1.000 srgb} bind def
-/col6 {1.000 1.000 0.000 srgb} bind def
-/col7 {1.000 1.000 1.000 srgb} bind def
-/col8 {0.000 0.000 0.560 srgb} bind def
-/col9 {0.000 0.000 0.690 srgb} bind def
-/col10 {0.000 0.000 0.820 srgb} bind def
-/col11 {0.530 0.810 1.000 srgb} bind def
-/col12 {0.000 0.560 0.000 srgb} bind def
-/col13 {0.000 0.690 0.000 srgb} bind def
-/col14 {0.000 0.820 0.000 srgb} bind def
-/col15 {0.000 0.560 0.560 srgb} bind def
-/col16 {0.000 0.690 0.690 srgb} bind def
-/col17 {0.000 0.820 0.820 srgb} bind def
-/col18 {0.560 0.000 0.000 srgb} bind def
-/col19 {0.690 0.000 0.000 srgb} bind def
-/col20 {0.820 0.000 0.000 srgb} bind def
-/col21 {0.560 0.000 0.560 srgb} bind def
-/col22 {0.690 0.000 0.690 srgb} bind def
-/col23 {0.820 0.000 0.820 srgb} bind def
-/col24 {0.500 0.190 0.000 srgb} bind def
-/col25 {0.630 0.250 0.000 srgb} bind def
-/col26 {0.750 0.380 0.000 srgb} bind def
-/col27 {1.000 0.500 0.500 srgb} bind def
-/col28 {1.000 0.630 0.630 srgb} bind def
-/col29 {1.000 0.750 0.750 srgb} bind def
-/col30 {1.000 0.880 0.880 srgb} bind def
-/col31 {1.000 0.840 0.000 srgb} bind def
-
-end
-save
--1.5 176.0 translate
- 90 rotate
-1 -1 scale
-
-/cp {closepath} bind def
-/ef {eofill} bind def
-/gr {grestore} bind def
-/gs {gsave} bind def
-/sa {save} bind def
-/rs {restore} bind def
-/l {lineto} bind def
-/m {moveto} bind def
-/rm {rmoveto} bind def
-/n {newpath} bind def
-/s {stroke} bind def
-/sh {show} bind def
-/slc {setlinecap} bind def
-/slj {setlinejoin} bind def
-/slw {setlinewidth} bind def
-/srgb {setrgbcolor} bind def
-/rot {rotate} bind def
-/sc {scale} bind def
-/sd {setdash} bind def
-/ff {findfont} bind def
-/sf {setfont} bind def
-/scf {scalefont} bind def
-/sw {stringwidth} bind def
-/tr {translate} bind def
-/tnt {dup dup currentrgbcolor
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add
- 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
- bind def
-/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
- 4 -2 roll mul srgb} bind def
- /DrawEllipse {
- /endangle exch def
- /startangle exch def
- /yrad exch def
- /xrad exch def
- /y exch def
- /x exch def
- /savematrix mtrx currentmatrix def
- x y tr xrad yrad sc 0 0 1 startangle endangle arc
- closepath
- savematrix setmatrix
- } def
-
-/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
-/$F2psEnd {$F2psEnteredState restore end} def
-%%EndProlog
-
-$F2psBegin
-10 setmiterlimit
-n 0 612 m 0 0 l 792 0 l 792 612 l cp clip
- 0.06000 0.06000 sc
-%%Page: 1 1
-/Times-Roman ff 180.00 scf sf
-4800 4125 m
-gs 1 -1 sc (Erlang control process) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-3900 8250 m
-gs 1 -1 sc (C-process) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-900 4200 m
-gs 1 -1 sc (Erlang client) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-4275 3525 m
-gs 1 -1 sc (Link) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-2543 3786 m
-gs 1 -1 sc 35.0 rot (Connection reference) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-3000 3900 m
-gs 1 -1 sc (request) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-3000 4350 m
-gs 1 -1 sc (response) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-2850 4650 m
-gs 1 -1 sc (monitor) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-2339 3449 m
-gs 1 -1 sc 35.0 rot (Connect request) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-2850 7800 m
-gs 1 -1 sc (Supervisor thread) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-4650 7575 m
-gs 1 -1 sc (Database handler thread) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-4425 6825 m
-gs 1 -1 sc (request) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-4425 4950 m
-gs 1 -1 sc (response) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-2325 6000 m
-gs 1 -1 sc (Erlang port) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-1800 6975 m
-gs 1 -1 sc (Exit signal propagation) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-3375 5850 m
-gs 1 -1 sc (shutdown) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-1650 5175 m
-gs 1 -1 sc (Exit signal propagation) col-1 sh gr
-/Times-Roman ff 180.00 scf sf
-3675 2100 m
-gs 1 -1 sc (Erlang Supervisor) col-1 sh gr
-7.500 slw
-% Arc
-gs n 2737.5 5737.5 488.9 -175.6 -4.4 arc
-gs col-1 s gr
- gr
-
-% Ellipse
-n 4200 2700 474 474 0 360 DrawEllipse gs col-1 s gr
-
-% Ellipse
-n 4275 7500 474 474 0 360 DrawEllipse gs col-1 s gr
-
-% Ellipse
-n 4200 4125 474 474 0 360 DrawEllipse gs col-1 s gr
-
-% Ellipse
-n 2325 4275 474 474 0 360 DrawEllipse gs col-1 s gr
-
-% Polyline
-gs clippath
-4230 3453 m 4200 3573 l 4170 3453 l 4170 3615 l 4230 3615 l cp clip
-4170 3297 m 4200 3177 l 4230 3297 l 4230 3135 l 4170 3135 l cp clip
-n 4200 3150 m 4200 3600 l gs col-1 s gr gr
-
-% arrowhead
-n 4170 3297 m 4200 3177 l 4230 3297 l 4200 3297 l 4170 3297 l cp gs 0.00 setgray ef gr col-1 s
-% arrowhead
-n 4230 3453 m 4200 3573 l 4170 3453 l 4200 3453 l 4230 3453 l cp gs 0.00 setgray ef gr col-1 s
-% Polyline
-gs clippath
-2997 4230 m 2877 4200 l 2997 4170 l 2835 4170 l 2835 4230 l cp clip
-n 3675 4200 m 2850 4200 l gs col-1 s gr gr
-
-% arrowhead
-n 2997 4230 m 2877 4200 l 2997 4170 l 2997 4200 l 2997 4230 l cp gs 0.00 setgray ef gr col-1 s
-% Polyline
-gs clippath
-3615 2616 m 3728 2566 l 3652 2664 l 3780 2565 l 3744 2517 l cp clip
-n 2100 3825 m 3750 2550 l gs col-1 s gr gr
-
-% arrowhead
-n 3615 2616 m 3728 2566 l 3652 2664 l col-1 s
-% Polyline
-gs clippath
-2764 3768 m 2647 3810 l 2731 3718 l 2596 3808 l 2629 3858 l cp clip
-n 3837 3017 m 2625 3825 l gs col-1 s gr gr
-
-% arrowhead
-n 2764 3768 m 2647 3810 l 2731 3718 l col-1 s
-% Polyline
-gs clippath
-3528 3945 m 3648 3975 l 3528 4005 l 3690 4005 l 3690 3945 l cp clip
-n 2775 3975 m 3675 3975 l gs col-1 s gr gr
-
-% arrowhead
-n 3528 3945 m 3648 3975 l 3528 4005 l 3528 3975 l 3528 3945 l cp gs 0.00 setgray ef gr col-1 s
-% Polyline
-gs clippath
-2922 4530 m 2802 4500 l 2922 4470 l 2760 4470 l 2760 4530 l cp clip
-n 3825 4500 m 2775 4500 l gs col-1 s gr gr
-
-% arrowhead
-n 2922 4530 m 2802 4500 l 2922 4470 l 2922 4500 l 2922 4530 l cp gs 0.00 setgray ef gr col-1 s
-% Polyline
-gs clippath
-4380 6903 m 4350 7023 l 4320 6903 l 4320 7065 l 4380 7065 l cp clip
-4320 4722 m 4350 4602 l 4380 4722 l 4380 4560 l 4320 4560 l cp clip
-n 4350 4575 m 4350 7050 l gs col-1 s gr gr
-
-% arrowhead
-n 4320 4722 m 4350 4602 l 4380 4722 l col-1 s
-% arrowhead
-n 4380 6903 m 4350 7023 l 4320 6903 l col-1 s
-% Polyline
-gs clippath
-4155 6978 m 4125 7098 l 4095 6978 l 4095 7140 l 4155 7140 l cp clip
-n 4125 4575 m 4125 7125 l gs col-1 s gr gr
-
-% arrowhead
-n 4155 6978 m 4125 7098 l 4095 6978 l col-1 s
-% Polyline
-n 2250 5700 m 3225 5700 l 3225 6300 l 2250 6300 l cp gs col-1 s gr
-% Polyline
-gs clippath
-3008 6425 m 2944 6319 l 3050 6383 l 2936 6268 l 2893 6311 l cp clip
-n 3900 7275 m 2925 6300 l gs col-1 s gr gr
-
-% arrowhead
-n 3008 6425 m 2944 6319 l 3050 6383 l 3029 6404 l 3008 6425 l cp gs 0.00 setgray ef gr col-1 s
-% Polyline
-gs clippath
-3843 4646 m 3954 4592 l 3881 4692 l 4006 4588 l 3967 4542 l cp clip
-n 3075 5325 m 3975 4575 l gs col-1 s gr gr
-
-% arrowhead
-n 3843 4646 m 3954 4592 l 3881 4692 l 3862 4669 l 3843 4646 l cp gs 0.00 setgray ef gr col-1 s
-% Interp Spline
-gs n 4125 7200 m
- 4001.9 7267.7 3964.4 7305.2 3975 7350 curveto
- 3990.8 7416.7 4184.2 7358.3 4200 7425 curveto
- 4214.1 7484.7 4035.9 7515.3 4050 7575 curveto
- 4065.8 7641.7 4271.5 7600.2 4275 7650 curveto
- 4277.5 7685.2 4133.6 7671.8 4125 7725 curveto
- 4116.8 7775.5 4154.3 7813.0 4275 7875 curveto
- gs col-1 s gr
- gr
-
-% Interp Spline
-gs n 4425 7088 m
- 4301.9 7155.7 4264.4 7193.2 4275 7238 curveto
- 4290.8 7304.7 4484.2 7246.3 4500 7313 curveto
- 4514.1 7372.7 4335.9 7403.3 4350 7463 curveto
- 4365.8 7529.7 4571.5 7488.2 4575 7538 curveto
- 4577.5 7573.2 4433.6 7559.8 4425 7613 curveto
- 4416.8 7663.5 4454.3 7701.0 4575 7763 curveto
- gs col-1 s gr
- gr
-
-showpage
-$F2psEnd
-rs
diff --git a/lib/odbc/test/odbc_query_SUITE.erl b/lib/odbc/test/odbc_query_SUITE.erl
index 062373afa0..56550bfaa6 100644
--- a/lib/odbc/test/odbc_query_SUITE.erl
+++ b/lib/odbc/test/odbc_query_SUITE.erl
@@ -43,7 +43,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
case odbc_test_lib:odbc_check() of
ok ->
- [sql_query, next, {group, scrollable_cursors}, select_count,
+ [stored_proc, sql_query, next, {group, scrollable_cursors}, select_count,
select_next, select_relative, select_absolute,
create_table_twice, delete_table_twice, duplicate_key,
not_connection_owner, no_result_set, query_error,
@@ -172,6 +172,26 @@ end_per_testcase(_Case, Config) ->
%%-------------------------------------------------------------------------
%% Test cases starts here.
%%-------------------------------------------------------------------------
+stored_proc(doc)->
+ ["Test stored proc with OUT param"];
+stored_proc(suite) -> [];
+stored_proc(Config) when is_list(Config) ->
+ case ?RDBMS of
+ X when X == oracle; X == postgres->
+ Ref = ?config(connection_ref, Config),
+ {updated, _} =
+ odbc:sql_query(Ref,
+ ?RDBMS:stored_proc_integer_out()),
+ Result = ?RDBMS:query_result(),
+ Result =
+ ?RDBMS:param_query(Ref),
+ {updated, _} =
+ odbc:sql_query(Ref, ?RDBMS:drop_proc()),
+ ok;
+ _ ->
+ {skip, "stored proc not yet supported"}
+ end.
+
sql_query(doc)->
["Test the common cases"];
sql_query(suite) -> [];
diff --git a/lib/odbc/test/oracle.erl b/lib/odbc/test/oracle.erl
index d74863d8c1..95cf7155dc 100644
--- a/lib/odbc/test/oracle.erl
+++ b/lib/odbc/test/oracle.erl
@@ -240,3 +240,30 @@ describe_floating() ->
{ok,[{"F",sql_double},{"R",sql_double},{"D",sql_double}]}.
describe_dec_num() ->
{ok,[{"MYDEC",{sql_decimal,9,3}},{"MYNUM",{sql_decimal,9,2}}]}.
+
+%-------------------------------------------------------------------------
+drop_proc() ->
+ "drop procedure test_proc1;".
+
+stored_proc_integer_out() ->
+ "create or replace PROCEDURE test_proc1(" ++
+ "int_a OUT NUMBER, " ++
+ "int_b OUT NUMBER) " ++
+ "is " ++
+ "begin " ++
+ " int_a := 123; " ++
+ " int_b := 456; " ++
+ "exception " ++
+ "WHEN NO_DATA_FOUND THEN " ++
+ " int_a := 0; " ++
+ " int_b := 0; " ++
+ "end;".
+
+param_query(Ref) ->
+ odbc:param_query(Ref, "call test_proc1(?,?)",
+ [{sql_integer, out, [0]},
+ {sql_integer, out, [0]}]).
+
+
+query_result() ->
+ {executed, 2, [{123, 456}]}.
diff --git a/lib/odbc/test/postgres.erl b/lib/odbc/test/postgres.erl
index d564dbd5ff..0c1761b835 100644
--- a/lib/odbc/test/postgres.erl
+++ b/lib/odbc/test/postgres.erl
@@ -293,3 +293,42 @@ describe_dec_num() ->
describe_timestamp() ->
{ok, [{"field", sql_timestamp}]}.
+
+%-------------------------------------------------------------------------
+drop_proc() ->
+ "drop function test_proc1(OUT integer, OUT integer);".
+
+stored_proc_integer_out() ->
+ "create or replace FUNCTION test_proc1(" ++
+ "OUT int_a INTEGER, " ++
+ "OUT int_b INTEGER) " ++
+ "AS $$ " ++
+ "BEGIN " ++
+ " int_a := 123; " ++
+ " int_b := 456; " ++
+ "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, [111]},
+ {sql_integer, out, [444]}]).
+
+query_result() ->
+ {executed, 2, [{111, 444}]}.