4
%% Copyright Ericsson AB 2011-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
24
%% Note: This directive should only be used in test suites.
27
%-------------------------------------------------------------------------
28
connection_string() ->
29
case test_server:os_type() of
31
"DSN=MySQL;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';";
35
"DSN=MySQLMac;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';"
39
case erlang:system_info(system_architecture) of
41
"DSN=MySQLSolaris10;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';";
43
"DSN=MySQLSolaris10i386;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';"
46
%-------------------------------------------------------------------------
48
{selected,["ID","DATA"],[{1,"bar"}]}.
51
{selected,["ID","DATA"],[{1,"foo"}]}.
53
selected_ID(N, next) ->
54
{selected,["ID"],[{N}]};
57
{error, driver_does_not_support_function}.
70
selected_relative_N(_)->
71
{error, driver_does_not_support_function}.
73
selected_absolute_N(_)->
74
{error, driver_does_not_support_function}.
76
selected_list_rows() ->
77
{selected,["ID", "DATA"],[[1, "bar"],[2,"foo"]]}.
80
{error, driver_does_not_support_function}.
82
{error, driver_does_not_support_function}.
84
{error, driver_does_not_support_function}.
86
{selected,["ID","DATA"],[[1,"bar"]]}.
89
[{selected,["ID", "DATA"],[{1, "bar"},{2, "foo"}]},
90
{selected,["ID"],[{"foo"}]}].
93
[{updated, 1},{updated, 1},
94
{selected,["ID", "DATA"],[{1, "foobar"},{2, "foo"}]},
95
{updated, 1}, {selected,["DATA"],[{"foo"}]}].
97
%-------------------------------------------------------------------------
103
create_var_char_table(Size) ->
104
" (FIELD varchar(" ++ integer_to_list(Size) ++ "))".
106
%-------------------------------------------------------------------------
110
2147483646. % 2147483647. %% 2^31 - 1
112
create_text_table() ->
115
%-------------------------------------------------------------------------
116
create_timestamp_table() ->
117
" (FIELD TIMESTAMP)".
119
%-------------------------------------------------------------------------
125
create_tiny_int_table() ->
128
tiny_int_min_selected() ->
129
{selected,["FIELD"],[{tiny_int_min()}]}.
131
tiny_int_max_selected() ->
132
{selected,["FIELD"], [{tiny_int_max()}]}.
134
%-------------------------------------------------------------------------
140
create_small_int_table() ->
143
small_int_min_selected() ->
144
{selected,["FIELD"],[{-32768}]}.
146
small_int_max_selected() ->
147
{selected,["FIELD"], [{32767}]}.
149
%-------------------------------------------------------------------------
155
create_int_table() ->
158
int_min_selected() ->
159
{selected,["FIELD"],[{-2147483648}]}.
161
int_max_selected() ->
162
{selected,["FIELD"], [{2147483647}]}.
164
%-------------------------------------------------------------------------
166
-9223372036854775808.
171
create_big_int_table() ->
174
big_int_min_selected() ->
175
{selected,["FIELD"], [{"-9223372036854775808"}]}.
177
big_int_max_selected() ->
178
{selected,["FIELD"], [{"9223372036854775807"}]}.
180
%-------------------------------------------------------------------------
186
create_bit_table() ->
189
bit_false_selected() ->
190
{selected,["FIELD"],[{"0"}]}.
192
bit_true_selected() ->
193
{selected,["FIELD"], [{"1"}]}.
195
%-------------------------------------------------------------------------
197
%% Do not test float min/max as value is only theoretical defined in
198
%% mysql and may vary depending on hardware.
200
create_float_table() ->
203
float_zero_selected() ->
204
{selected,["FIELD"],[{0.00000e+0}]}.
206
%-------------------------------------------------------------------------
218
create_real_table() ->
221
real_zero_selected() ->
222
{selected,["FIELD"],[{0.00000e+0}]}.
224
%-------------------------------------------------------------------------
225
param_select_small_int() ->
226
{selected,["FIELD"],[{1}, {2}]}.
228
param_select_int() ->
229
Int = small_int_max() + 1,
230
{selected,["FIELD"],[{1}, {Int}]}.
232
param_select_decimal() ->
233
{selected,["FIELD"],[{1},{2}]}.
235
param_select_numeric() ->
236
{selected,["FIELD"],[{1},{2}]}.
238
param_select_float() ->
239
{selected,["FIELD"],[{1.30000},{1.20000}]}.
241
param_select_real() ->
242
{selected,["FIELD"],[{1.30000},{1.20000}]}.
244
param_select_double() ->
245
{selected,["FIELD"],[{1.30000},{1.20000}]}.
247
param_select_mix() ->
248
{selected,["ID","DATA"],[{1, "foo"}, {2, "bar"}]}.
251
{selected,["ID","DATA"],[{1, "foobar"}, {2, "foobar"}, {3, "baz"}]}.
254
{selected,["ID","DATA"],[{3, "baz"}]}.
257
{selected,["ID","DATA"],[{1, "foo"},{3, "foo"}]}.
259
%-------------------------------------------------------------------------
260
describe_integer() ->
261
{ok,[{"myint1",sql_smallint},
262
{"myint2",sql_integer},
263
{"myint3",sql_integer}]}.
266
{ok,[{"str1",{sql_char,10}},
267
{"str2",{sql_char,10}},
268
{"str3",{sql_varchar,10}},
269
{"str4",{sql_varchar,10}}]}.
271
describe_floating() ->
272
{ok,[{"f",sql_real},{"r",sql_double},{"d",sql_double}]}.
273
describe_dec_num() ->
274
{ok,[{"mydec",{sql_decimal,9,3}},{"mynum",{sql_decimal,9,2}}]}.
276
describe_timestamp() ->
277
{ok, [{"FIELD", sql_timestamp}]}.