aboutsummaryrefslogtreecommitdiffstats
path: root/lib/odbc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/odbc')
-rw-r--r--lib/odbc/c_src/odbcserver.c71
-rw-r--r--lib/odbc/c_src/odbcserver.h3
-rw-r--r--lib/odbc/doc/src/databases.xml6
-rw-r--r--lib/odbc/doc/src/odbc.xml8
-rw-r--r--lib/odbc/src/odbc.appup.src6
-rw-r--r--lib/odbc/src/odbc.erl7
-rw-r--r--lib/odbc/src/odbc_internal.hrl3
-rw-r--r--lib/odbc/test/Makefile3
-rw-r--r--lib/odbc/test/mysql.erl277
-rw-r--r--lib/odbc/test/odbc.dynspec31
-rw-r--r--lib/odbc/test/odbc.spec24
-rw-r--r--lib/odbc/test/odbc.spec.win5
-rw-r--r--lib/odbc/test/odbc_connect_SUITE.erl237
-rw-r--r--lib/odbc/test/odbc_data_type_SUITE.erl516
-rw-r--r--lib/odbc/test/odbc_query_SUITE.erl64
-rw-r--r--lib/odbc/test/odbc_start_SUITE.erl27
-rw-r--r--lib/odbc/test/odbc_test.hrl13
-rw-r--r--lib/odbc/test/odbc_test_lib.erl83
-rw-r--r--lib/odbc/test/oracle.erl12
-rw-r--r--lib/odbc/test/postgres.erl23
-rw-r--r--lib/odbc/test/sqlserver.erl12
-rw-r--r--lib/odbc/vsn.mk2
22 files changed, 936 insertions, 497 deletions
diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index d61ce940c3..ab2d7fe210 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -90,7 +90,7 @@
Datatype - USER_INT | USER_SMALL_INT | {USER_DECIMAL, Precision, Scale} |
{USER_NMERIC, Precision, Scale} | {USER_CHAR, Max} | {USER_VARCHAR, Max} |
{USER_WVARCHAR, Max} | {USER_FLOAT, Precision} | USER_REAL | USER_DOUBLE |
- USER_TIMESTAMP
+ USER_TIMESTAMP | {USER_WLONGVARCHAR, Max}
Scale - integer
Precision - integer
Max - integer
@@ -173,7 +173,7 @@ static db_result_msg encode_row_count(SQLINTEGER num_of_rows,
db_state *state);
static void encode_column_dyn(db_column column, int column_nr,
db_state *state);
-static void encode_data_type(SQLINTEGER sql_type, SQLINTEGER size,
+static void encode_data_type(SQLSMALLINT sql_type, SQLINTEGER size,
SQLSMALLINT decimal_digits, db_state *state);
static Boolean decode_params(db_state *state, byte *buffer, int *index, param_array **params,
int i, int j);
@@ -221,7 +221,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
int num_param_values, db_state* state);
static void init_param_statement(int cols,
- int num_param_values,
+ SQLLEN num_param_values,
db_state *state,
param_status *status);
@@ -435,7 +435,7 @@ static db_result_msg db_connect(byte *args, db_state *state)
diagnos diagnos;
byte *connStrIn;
int erl_auto_commit_mode, erl_trace_driver,
- use_srollable_cursors, tuple_row_state, binary_strings;
+ use_srollable_cursors, tuple_row_state, binary_strings;
erl_auto_commit_mode = args[0];
erl_trace_driver = args[1];
@@ -757,8 +757,9 @@ static db_result_msg db_select(byte *args, db_state *state)
static db_result_msg db_param_query(byte *buffer, db_state *state)
{
byte *sql;
- db_result_msg msg;
- int i, num_param_values, ver = 0,
+ db_result_msg msg;
+ SQLLEN num_param_values;
+ int i, ver = 0,
erl_type = 0, index = 0, size = 0, cols = 0;
long long_num_param_values;
param_status param_status;
@@ -771,6 +772,7 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
}
associated_result_set(state) = FALSE;
param_query(state) = TRUE;
+ out_params(state) = FALSE;
msg = encode_empty_message();
@@ -785,7 +787,7 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
ei_decode_long(buffer, &index, &long_num_param_values);
- num_param_values = (int)long_num_param_values;
+ num_param_values = (SQLLEN)long_num_param_values;
ei_decode_list_header(buffer, &index, &cols);
@@ -1002,12 +1004,16 @@ static db_result_msg encode_result(db_state *state)
db_result_msg msg;
int elements, update, num_of_rows = 0;
char *atom;
+ diagnos diagnos;
msg = encode_empty_message();
if(!sql_success(SQLNumResultCols(statement_handle(state),
&num_of_columns))) {
- DO_EXIT(EXIT_COLS);
+ diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
+ msg = encode_error_message(diagnos.error_msg);
+ clean_state(state);
+ return msg;
}
if (num_of_columns == 0) {
@@ -1021,7 +1027,10 @@ static db_result_msg encode_result(db_state *state)
}
if(!sql_success(SQLRowCount(statement_handle(state), &RowCountPtr))) {
- DO_EXIT(EXIT_ROWS);
+ diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
+ msg = encode_error_message(diagnos.error_msg);
+ clean_state(state);
+ return msg;
}
if(param_query(state) && update) {
@@ -1220,7 +1229,7 @@ static db_result_msg encode_column_name_list(SQLSMALLINT num_of_columns,
&nullable)))
DO_EXIT(EXIT_DESC);
- if(sql_type == SQL_LONGVARCHAR || sql_type == SQL_LONGVARBINARY)
+ if(sql_type == SQL_LONGVARCHAR || sql_type == SQL_LONGVARBINARY || sql_type == SQL_WLONGVARCHAR)
size = MAXCOLSIZE;
(columns(state)[i]).type.decimal_digits = dec_digits;
@@ -1452,7 +1461,7 @@ static void encode_column_dyn(db_column column, int column_nr,
}
}
-static void encode_data_type(SQLINTEGER sql_type, SQLINTEGER size,
+static void encode_data_type(SQLSMALLINT sql_type, SQLINTEGER size,
SQLSMALLINT decimal_digits, db_state *state)
{
switch(sql_type) {
@@ -1529,6 +1538,11 @@ static void encode_data_type(SQLINTEGER sql_type, SQLINTEGER size,
case SQL_LONGVARCHAR:
ei_x_encode_atom(&dynamic_buffer(state), "SQL_LONGVARCHAR");
break;
+ case SQL_WLONGVARCHAR:
+ ei_x_encode_tuple_header(&dynamic_buffer(state), 2);
+ ei_x_encode_atom(&dynamic_buffer(state), "sql_wlongvarchar");
+ ei_x_encode_long(&dynamic_buffer(state), size);
+ break;
case SQL_VARBINARY:
ei_x_encode_atom(&dynamic_buffer(state), "SQL_VARBINARY");
break;
@@ -2007,7 +2021,7 @@ static void init_driver(int erl_auto_commit_mode, int erl_trace_driver,
db_state *state)
{
- int auto_commit_mode, trace_driver;
+ SQLLEN auto_commit_mode, trace_driver;
if(erl_auto_commit_mode == ON) {
auto_commit_mode = SQL_AUTOCOMMIT_ON;
@@ -2057,7 +2071,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
ei_decode_long(buffer, index, &user_type);
- params->type.strlen_or_indptr = (SQLINTEGER)NULL;
+ params->type.strlen_or_indptr = (SQLLEN)NULL;
params->type.strlen_or_indptr_array = NULL;
params->type.decimal_digits = (SQLINTEGER)0;
@@ -2131,10 +2145,14 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
break;
case USER_WCHAR:
case USER_WVARCHAR:
- if(user_type == USER_WCHAR) {
- params->type.sql = SQL_WCHAR;
- } else {
- params->type.sql = SQL_WVARCHAR;
+ case USER_WLONGVARCHAR:
+ switch (user_type) {
+ case USER_WCHAR:
+ params->type.sql = SQL_WCHAR; break;
+ case USER_WVARCHAR:
+ params->type.sql = SQL_WVARCHAR; break;
+ default:
+ params->type.sql = SQL_WLONGVARCHAR; break;
}
ei_decode_long(buffer, index, &length);
/* Max string length + string terminator */
@@ -2206,7 +2224,7 @@ static void init_param_column(param_array *params, byte *buffer, int *index,
}
-static void init_param_statement(int cols, int num_param_values,
+static void init_param_statement(int cols, SQLLEN num_param_values,
db_state *state, param_status *status)
{
int i;
@@ -2234,11 +2252,11 @@ static void init_param_statement(int cols, int num_param_values,
DO_EXIT(EXIT_PARAM_ARRAY);
}
- /* Note the (int *) cast is correct as the API function SQLSetStmtAttr
+ /* Note the (SQLLEN *) cast is correct as the API function SQLSetStmtAttr
takes either an interger or a pointer depending on the attribute */
if(!sql_success(SQLSetStmtAttr(statement_handle(state),
SQL_ATTR_PARAMSET_SIZE,
- (int *)num_param_values,
+ (SQLLEN *)num_param_values,
0))) {
DO_EXIT(EXIT_PARAM_ARRAY);
}
@@ -2300,6 +2318,7 @@ static db_result_msg map_sql_2_c_column(db_column* column)
break;
case SQL_WCHAR:
case SQL_WVARCHAR:
+ case SQL_WLONGVARCHAR:
column -> type.len = (column -> type.col_size + 1)*sizeof(SQLWCHAR);
column -> type.c = SQL_C_WCHAR;
column -> type.strlen_or_indptr = SQL_NTS;
@@ -2308,21 +2327,21 @@ static db_result_msg map_sql_2_c_column(db_column* column)
case SQL_DECIMAL:
map_dec_num_2_c_column(&(column -> type), column -> type.col_size,
column -> type.decimal_digits);
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_TINYINT:
case SQL_INTEGER:
case SQL_SMALLINT:
column -> type.len = sizeof(SQLINTEGER);
column -> type.c = SQL_C_SLONG;
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_REAL:
case SQL_FLOAT:
case SQL_DOUBLE:
column -> type.len = sizeof(double);
column -> type.c = SQL_C_DOUBLE;
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
@@ -2334,17 +2353,17 @@ static db_result_msg map_sql_2_c_column(db_column* column)
case SQL_TYPE_TIMESTAMP:
column -> type.len = sizeof(TIMESTAMP_STRUCT);
column -> type.c = SQL_C_TYPE_TIMESTAMP;
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_BIGINT:
column -> type.len = DEC_NUM_LENGTH;
column -> type.c = SQL_C_CHAR;
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_BIT:
column -> type.len = sizeof(byte);
column -> type.c = SQL_C_BIT;
- column -> type.strlen_or_indptr = (SQLINTEGER)NULL;
+ column -> type.strlen_or_indptr = (SQLLEN)NULL;
break;
case SQL_UNKNOWN_TYPE:
msg = encode_error_message("Unknown column type");
diff --git a/lib/odbc/c_src/odbcserver.h b/lib/odbc/c_src/odbcserver.h
index 3e2b22ab7d..56b6148777 100644
--- a/lib/odbc/c_src/odbcserver.h
+++ b/lib/odbc/c_src/odbcserver.h
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2002-2010. All Rights Reserved.
+ * Copyright Ericsson AB 2002-2011. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -115,6 +115,7 @@
#define USER_WCHAR 12
#define USER_WVARCHAR 13
#define USER_TIMESTAMP 14
+#define USER_WLONGVARCHAR 15
/*------------------------ TYPDEFS ----------------------------------*/
diff --git a/lib/odbc/doc/src/databases.xml b/lib/odbc/doc/src/databases.xml
index a6ba0e5245..34e1d51255 100644
--- a/lib/odbc/doc/src/databases.xml
+++ b/lib/odbc/doc/src/databases.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2002</year><year>2010</year>
+ <year>2002</year><year>2011</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -205,6 +205,10 @@ when p >= 16 </cell>
<cell align="left" valign="middle">String | Binary (configurable)</cell>
</row>
<row>
+ <cell align="left" valign="middle">SQL_WLONGVARCHAR(size) </cell>
+ <cell align="left" valign="middle">Unicode binary encoded as UTF16 little endian.</cell>
+ </row>
+ <row>
<cell align="left" valign="middle">SQL_BINARY</cell>
<cell align="left" valign="middle">String | Binary (configurable)</cell>
</row>
diff --git a/lib/odbc/doc/src/odbc.xml b/lib/odbc/doc/src/odbc.xml
index 70d8cfbe22..8a58dc2848 100644
--- a/lib/odbc/doc/src/odbc.xml
+++ b/lib/odbc/doc/src/odbc.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1999</year><year>2010</year>
+ <year>1999</year><year>2011</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -102,7 +102,7 @@
{sql_decimal, precision(), scale()} |
{sql_numeric, precision(), scale()} |
{sql_char, size()} | {sql_wchar, size()} | {sql_varchar, size()} | {sql_wvarchar, size()}| {sql_float, precision()} |
- {sql_float, precision()} | sql_real | sql_double | sql_bit | atom()
+ {sql_wlongvarchar, size()} | {sql_float, precision()} | sql_real | sql_double | sql_bit | atom()
</code>
<code type="none">
precision() = integer() </code>
@@ -138,7 +138,7 @@
<fsummary>Opens a connection to the database. </fsummary>
<type>
<v>ConnectStr = string()</v>
- <d>An example of a connection string:<c>"DSN=sql-server;UID=aladdin;PWD=sesame"</c>where DSN is your ODBC Data Source Name, UID is a database user id and PWD is the password for that user. These are usually the attributes required in the connection string, but some drivers have other driver specific attributes, for example<c>"DSN=Oracle8;DBQ=gandalf;UID=aladdin;PWD=sesame"</c>where DBQ is your TNSNAMES.ORA entry name e.g. some Oracle specific configuration attribute.</d>
+ <d>An example of a connection string: <c>"DSN=sql-server;UID=aladdin;PWD=sesame"</c> where DSN is your ODBC Data Source Name, UID is a database user id and PWD is the password for that user. These are usually the attributes required in the connection string, but some drivers have other driver specific attributes, for example <c>"DSN=Oracle8;DBQ=gandalf;UID=aladdin;PWD=sesame"</c> where DBQ is your TNSNAMES.ORA entry name e.g. some Oracle specific configuration attribute.</d>
<v>Options = [] | [option()]</v>
<d>All options has default values. </d>
<v>option() = {auto_commit, on | off} | {timeout, milliseconds()}
@@ -432,7 +432,7 @@
<desc>
<p>Selects <c>N</c> consecutive rows of the result set. If
<c>Position</c> is <c>next</c> it is semantically equivalent
- of calling <c>next/[1,2]</c><c>N</c> times. If
+ of calling <c>next/[1,2]</c> <c>N</c> times. If
<c>Position</c> is <c>{relative, Pos}</c>, <c>Pos</c> will be
used as an offset from the current cursor position to
determine the first selected row. If <c>Position</c> is
diff --git a/lib/odbc/src/odbc.appup.src b/lib/odbc/src/odbc.appup.src
index 2a6667ccd3..f3a3af8c29 100644
--- a/lib/odbc/src/odbc.appup.src
+++ b/lib/odbc/src/odbc.appup.src
@@ -1,8 +1,10 @@
%% -*- erlang -*-
{"%VSN%",
[
- {"2.10.9", [{restart_application, ssl}]}
+ {"2.10.10", [{restart_application, odbc}]},
+ {"2.10.9", [{restart_application, odbc}]}
],
[
- {"2.10.9", [{restart_application, ssl}]}
+ {"2.10.10", [{restart_application, odbc}]},
+ {"2.10.9", [{restart_application, odbc}]}
]}.
diff --git a/lib/odbc/src/odbc.erl b/lib/odbc/src/odbc.erl
index 83d9f33102..68497292db 100644
--- a/lib/odbc/src/odbc.erl
+++ b/lib/odbc/src/odbc.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -431,7 +431,7 @@ init(Args) ->
erlang:monitor(process, ClientPid),
- Inet = case gen_tcp:listen(0, [inet6]) of
+ Inet = case gen_tcp:listen(0, [inet6, {ip, loopback}]) of
{ok, Dummyport} ->
gen_tcp:close(Dummyport),
inet6;
@@ -925,6 +925,9 @@ fix_params({{sql_wchar, Max}, InOut, Values}) ->
fix_params({{sql_wvarchar, Max}, InOut, Values}) ->
NewValues = string_terminate(Values),
{?USER_WVARCHAR, Max, fix_inout(InOut), NewValues};
+fix_params({{sql_wlongvarchar, Max}, InOut, Values}) ->
+ NewValues = string_terminate(Values),
+ {?USER_WLONGVARCHAR, Max, fix_inout(InOut), NewValues};
fix_params({{sql_float, Precision}, InOut, Values}) ->
{?USER_FLOAT, Precision, fix_inout(InOut), Values};
fix_params({sql_real, InOut, Values}) ->
diff --git a/lib/odbc/src/odbc_internal.hrl b/lib/odbc/src/odbc_internal.hrl
index aa60120f9a..bd80cdc659 100644
--- a/lib/odbc/src/odbc_internal.hrl
+++ b/lib/odbc/src/odbc_internal.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -72,6 +72,7 @@
-define(USER_WCHAR, 12).
-define(USER_WVARCHAR, 13).
-define(USER_TIMESTAMP, 14).
+-define(USER_WLONGVARCHAR, 15).
%% INPUT & OUTPUT TYPE
-define(IN, 0).
diff --git a/lib/odbc/test/Makefile b/lib/odbc/test/Makefile
index ec2bcc67b5..bc6449242e 100644
--- a/lib/odbc/test/Makefile
+++ b/lib/odbc/test/Makefile
@@ -34,7 +34,8 @@ MODULES= \
odbc_test_lib \
oracle \
sqlserver \
- postgres
+ postgres \
+ mysql
EBIN = .
diff --git a/lib/odbc/test/mysql.erl b/lib/odbc/test/mysql.erl
new file mode 100644
index 0000000000..c990793213
--- /dev/null
+++ b/lib/odbc/test/mysql.erl
@@ -0,0 +1,277 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2011-2011. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%
+
+-module(mysql).
+
+%% Note: This directive should only be used in test suites.
+-compile(export_all).
+
+%-------------------------------------------------------------------------
+connection_string() ->
+ case test_server:os_type() of
+ {unix, linux} ->
+ "DSN=MySQL;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';";
+ {unix, sunos} ->
+ solaris_str();
+ {unix, darwin} ->
+ "DSN=MySQLMac;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';"
+ end.
+
+solaris_str() ->
+ case erlang:system_info(system_architecture) of
+ "sparc" ++ _ ->
+ "DSN=MySQLSolaris10;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';";
+ "i386" ++ _ ->
+ "DSN=MySQLSolaris10i386;Database=odbctest;Uid=odbctest;Pwd=gurka;CHARSET=utf8;SSTMT=SET NAMES 'utf8';"
+ end.
+
+%-------------------------------------------------------------------------
+insert_result() ->
+ {selected,["ID","DATA"],[{1,"bar"}]}.
+
+update_result() ->
+ {selected,["ID","DATA"],[{1,"foo"}]}.
+
+selected_ID(N, next) ->
+ {selected,["ID"],[{N}]};
+
+selected_ID(_, _) ->
+ {error, driver_does_not_support_function}.
+
+selected_next_N(1)->
+ {selected,["ID"],
+ [{1},
+ {2},
+ {3}]};
+
+selected_next_N(2)->
+ {selected,["ID"],
+ [{4},
+ {5}]}.
+
+selected_relative_N(_)->
+ {error, driver_does_not_support_function}.
+
+selected_absolute_N(_)->
+ {error, driver_does_not_support_function}.
+
+selected_list_rows() ->
+ {selected,["ID", "DATA"],[[1, "bar"],[2,"foo"]]}.
+
+first_list_rows() ->
+ {error, driver_does_not_support_function}.
+last_list_rows() ->
+ {error, driver_does_not_support_function}.
+prev_list_rows() ->
+ {error, driver_does_not_support_function}.
+next_list_rows() ->
+ {selected,["ID","DATA"],[[1,"bar"]]}.
+
+multiple_select()->
+ [{selected,["ID", "DATA"],[{1, "bar"},{2, "foo"}]},
+ {selected,["ID"],[{"foo"}]}].
+
+multiple_mix()->
+ [{updated, 1},{updated, 1},
+ {selected,["ID", "DATA"],[{1, "foobar"},{2, "foo"}]},
+ {updated, 1}, {selected,["DATA"],[{"foo"}]}].
+
+%-------------------------------------------------------------------------
+var_char_min() ->
+ 0.
+var_char_max() ->
+ 65535.
+
+create_var_char_table(Size) ->
+ " (FIELD varchar(" ++ integer_to_list(Size) ++ "))".
+
+%-------------------------------------------------------------------------
+text_min() ->
+ 1.
+text_max() ->
+ 2147483646. % 2147483647. %% 2^31 - 1
+
+create_text_table() ->
+ " (FIELD text)".
+
+%-------------------------------------------------------------------------
+create_timestamp_table() ->
+ " (FIELD TIMESTAMP)".
+
+%-------------------------------------------------------------------------
+tiny_int_min() ->
+ -128.
+tiny_int_max() ->
+ 127.
+
+create_tiny_int_table() ->
+ " (FIELD tinyint)".
+
+tiny_int_min_selected() ->
+ {selected,["FIELD"],[{tiny_int_min()}]}.
+
+tiny_int_max_selected() ->
+ {selected,["FIELD"], [{tiny_int_max()}]}.
+
+%-------------------------------------------------------------------------
+small_int_min() ->
+ -32768.
+small_int_max() ->
+ 32767.
+
+create_small_int_table() ->
+ " (FIELD smallint)".
+
+small_int_min_selected() ->
+ {selected,["FIELD"],[{-32768}]}.
+
+small_int_max_selected() ->
+ {selected,["FIELD"], [{32767}]}.
+
+%-------------------------------------------------------------------------
+int_min() ->
+ -2147483648.
+int_max() ->
+ 2147483647.
+
+create_int_table() ->
+ " (FIELD int)".
+
+int_min_selected() ->
+ {selected,["FIELD"],[{-2147483648}]}.
+
+int_max_selected() ->
+ {selected,["FIELD"], [{2147483647}]}.
+
+%-------------------------------------------------------------------------
+big_int_min() ->
+ -9223372036854775808.
+
+big_int_max() ->
+ 9223372036854775807.
+
+create_big_int_table() ->
+ " (FIELD bigint )".
+
+big_int_min_selected() ->
+ {selected,["FIELD"], [{"-9223372036854775808"}]}.
+
+big_int_max_selected() ->
+ {selected,["FIELD"], [{"9223372036854775807"}]}.
+
+%-------------------------------------------------------------------------
+bit_false() ->
+ 0.
+bit_true() ->
+ 1.
+
+create_bit_table() ->
+ " (FIELD bit)".
+
+bit_false_selected() ->
+ {selected,["FIELD"],[{"0"}]}.
+
+bit_true_selected() ->
+ {selected,["FIELD"], [{"1"}]}.
+
+%-------------------------------------------------------------------------
+
+%% Do not test float min/max as value is only theoretical defined in
+%% mysql and may vary depending on hardware.
+
+create_float_table() ->
+ " (FIELD float)".
+
+float_zero_selected() ->
+ {selected,["FIELD"],[{0.00000e+0}]}.
+
+%-------------------------------------------------------------------------
+real_min() ->
+ -3.40e+38.
+real_max() ->
+ 3.40e+38.
+
+real_underflow() ->
+ "-3.41e+38".
+
+real_overflow() ->
+ "3.41e+38".
+
+create_real_table() ->
+ " (FIELD real)".
+
+real_zero_selected() ->
+ {selected,["FIELD"],[{0.00000e+0}]}.
+
+%-------------------------------------------------------------------------
+param_select_small_int() ->
+ {selected,["FIELD"],[{1}, {2}]}.
+
+param_select_int() ->
+ Int = small_int_max() + 1,
+ {selected,["FIELD"],[{1}, {Int}]}.
+
+param_select_decimal() ->
+ {selected,["FIELD"],[{1},{2}]}.
+
+param_select_numeric() ->
+ {selected,["FIELD"],[{1},{2}]}.
+
+param_select_float() ->
+ {selected,["FIELD"],[{1.30000},{1.20000}]}.
+
+param_select_real() ->
+ {selected,["FIELD"],[{1.30000},{1.20000}]}.
+
+param_select_double() ->
+ {selected,["FIELD"],[{1.30000},{1.20000}]}.
+
+param_select_mix() ->
+ {selected,["ID","DATA"],[{1, "foo"}, {2, "bar"}]}.
+
+param_update() ->
+ {selected,["ID","DATA"],[{1, "foobar"}, {2, "foobar"}, {3, "baz"}]}.
+
+param_delete() ->
+ {selected,["ID","DATA"],[{3, "baz"}]}.
+
+param_select() ->
+ {selected,["ID","DATA"],[{1, "foo"},{3, "foo"}]}.
+
+%-------------------------------------------------------------------------
+describe_integer() ->
+ {ok,[{"myint1",sql_smallint},
+ {"myint2",sql_integer},
+ {"myint3",sql_integer}]}.
+
+describe_string() ->
+ {ok,[{"str1",{sql_char,10}},
+ {"str2",{sql_char,10}},
+ {"str3",{sql_varchar,10}},
+ {"str4",{sql_varchar,10}}]}.
+
+describe_floating() ->
+ {ok,[{"f",sql_real},{"r",sql_double},{"d",sql_double}]}.
+describe_dec_num() ->
+ {ok,[{"mydec",{sql_decimal,9,3}},{"mynum",{sql_decimal,9,2}}]}.
+
+describe_timestamp() ->
+ {ok, [{"FIELD", sql_timestamp}]}.
diff --git a/lib/odbc/test/odbc.dynspec b/lib/odbc/test/odbc.dynspec
deleted file mode 100644
index bb15edceed..0000000000
--- a/lib/odbc/test/odbc.dynspec
+++ /dev/null
@@ -1,31 +0,0 @@
-%% -*- erlang -*-
-%% You can test this file using this command.
-%% file:script("odbc.dynspec", [{'Os',"Unix"}]).
-
-Exists =
-fun() ->
- case code:lib_dir(odbc) of
- {error,bad_name} ->
- false;
- P ->
- %% Make sure that the odbc directory really
- %% contains the application (and not only documentation).
- case filelib:is_file(filename:join(P, "ebin/odbc.beam")) of
- false -> false;
- true ->
- %% We know that we don't have any odbc libraries
- %% installed on this computer.
- {ok,Host} = inet:gethostname(),
- Host =/= "netsim200"
- end
- end
-end,
-case Exists() of
- false ->
- NoOdbc = "No odbc application",
- [{skip, {odbc_connect_SUITE, NoOdbc}},
- {skip, {odbc_data_type_SUITE, NoOdbc}},
- {skip, {odbc_query_SUITE, NoOdbc}}];
- true ->
- []
-end.
diff --git a/lib/odbc/test/odbc.spec b/lib/odbc/test/odbc.spec
index edaf821c91..653f1a780e 100644
--- a/lib/odbc/test/odbc.spec
+++ b/lib/odbc/test/odbc.spec
@@ -1,25 +1 @@
{suites,"../odbc_test",all}.
-{skip_cases,"../odbc_test",odbc_data_type_SUITE,
- [varchar_upper_limit],
- "Known bug in database"}.
-{skip_cases,"../odbc_test",odbc_data_type_SUITE,
- [text_upper_limit],
- "Consumes too much resources"}.
-{skip_cases,"../odbc_test",odbc_data_type_SUITE,
- [bit_true],
- "Not supported by driver"}.
-{skip_cases,"../odbc_test",odbc_data_type_SUITE,
- [bit_false],
- "Not supported by driver"}.
-{skip_cases,"../odbc_test",odbc_query_SUITE,
- [multiple_select_result_sets],
- "Not supported by driver"}.
-{skip_cases,"../odbc_test",odbc_query_SUITE,
- [multiple_mix_result_sets],
- "Not supported by driver"}.
-{skip_cases,"../odbc_test",odbc_query_SUITE,
- [multiple_result_sets_error],
- "Not supported by driver"}.
-{skip_cases,"../odbc_test",odbc_query_SUITE,
- [param_insert_tiny_int],
- "Not supported by driver"}.
diff --git a/lib/odbc/test/odbc.spec.win b/lib/odbc/test/odbc.spec.win
deleted file mode 100644
index 1fd349d2c3..0000000000
--- a/lib/odbc/test/odbc.spec.win
+++ /dev/null
@@ -1,5 +0,0 @@
-{topcase, {dir, "../odbc_test"}}.
-{skip, {odbc_data_type_SUITE, big_int_lower_limit, "Not supported by sqlserver 7.0"}}.
-{skip, {odbc_data_type_SUITE, big_int_upper_limit, "Not supported by sqlserver7.0"}}.
-{skip, {odbc_data_type_SUITE, text_upper_limit, "Consumes too much resources"}}.
-
diff --git a/lib/odbc/test/odbc_connect_SUITE.erl b/lib/odbc/test/odbc_connect_SUITE.erl
index 6a2268f40e..a076c4dfff 100644
--- a/lib/odbc/test/odbc_connect_SUITE.erl
+++ b/lib/odbc/test/odbc_connect_SUITE.erl
@@ -76,16 +76,26 @@ end_per_group(_GroupName, Config) ->
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
-init_per_suite(Config) ->
- application:start(odbc),
- case catch odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]) of
- {ok, Ref} ->
- odbc:disconnect(Ref),
- [{tableName, odbc_test_lib:unique_table_name()} | Config];
- _ ->
- {skip, "ODBC is not properly setup"}
- end.
+init_per_suite(Config) when is_list(Config) ->
+ case odbc_test_lib:skip() of
+ true ->
+ {skip, "ODBC not supported"};
+ false ->
+ case (catch odbc:start()) of
+ ok ->
+ case catch odbc:connect(?RDBMS:connection_string(),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()) of
+ {ok, Ref} ->
+ odbc:disconnect(Ref),
+ [{tableName, odbc_test_lib:unique_table_name()} | Config];
+ _ ->
+ {skip, "ODBC is not properly setup"}
+ end;
+ _ ->
+ {skip,"ODBC not startable"}
+ end
+ end.
+
%%--------------------------------------------------------------------
%% Function: end_per_suite(Config) -> _
%% Config - [tuple()]
@@ -93,8 +103,7 @@ init_per_suite(Config) ->
%% Description: Cleanup after the whole suite
%%--------------------------------------------------------------------
end_per_suite(_Config) ->
- application:stop(odbc),
- ok.
+ application:stop(odbc).
%%--------------------------------------------------------------------
%% Function: init_per_testcase(Case, Config) -> Config
@@ -124,15 +133,13 @@ init_per_testcase(_TestCase, Config) ->
%% Description: Cleanup after each test case
%%--------------------------------------------------------------------
end_per_testcase(_TestCase, Config) ->
- %% Clean up if needed
Table = ?config(tableName, Config),
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
- Result = odbc:sql_query(Ref, "DROP TABLE " ++ Table),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
+ Result = odbc:sql_query(Ref, "DROP TABLE " ++ Table),
io:format("Drop table: ~p ~p~n", [Table, Result]),
odbc:disconnect(Ref),
Dog = ?config(watchdog, Config),
- test_server:timetrap_cancel(Dog),
- ok.
+ test_server:timetrap_cancel(Dog).
%%-------------------------------------------------------------------------
%% Test cases starts here.
@@ -142,13 +149,15 @@ commit(doc)->
commit(suite) -> [];
commit(Config) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
+ TransStr = transaction_support_str(?RDBMS),
+
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10))"),
+ " (ID integer, DATA varchar(10))" ++ TransStr),
{updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1,'bar')"),
@@ -173,50 +182,47 @@ commit(Config) ->
{'EXIT', {function_clause, _}} =
(catch odbc:commit(Ref, commit, -1)),
- ok = odbc:disconnect(Ref),
-
- ok.
+ ok = odbc:disconnect(Ref).
%%-------------------------------------------------------------------------
rollback(doc)->
["Test the use of explicit rollback"];
rollback(suite) -> [];
rollback(Config) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
- {updated, _} =
- odbc:sql_query(Ref,
+ TransStr = transaction_support_str(?RDBMS),
+
+ {updated, _} =
+ odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10))"),
- {updated, 1} =
+ " (ID integer, DATA varchar(10))" ++ TransStr),
+ {updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++ " VALUES(1,'bar')"),
ok = odbc:commit(Ref, commit),
- {updated, 1} =
+ {updated, 1} =
odbc:sql_query(Ref, "UPDATE " ++ Table ++
- " SET DATA = 'foo' WHERE ID = 1"),
+ " SET DATA = 'foo' WHERE ID = 1"),
ok = odbc:commit(Ref, rollback),
InsertResult = ?RDBMS:insert_result(),
- InsertResult =
+ InsertResult =
odbc:sql_query(Ref, "SELECT * FROM " ++ Table),
-
- {updated, 1} =
+ {updated, 1} =
odbc:sql_query(Ref, "UPDATE " ++ Table ++
- " SET DATA = 'foo' WHERE ID = 1"),
+ " SET DATA = 'foo' WHERE ID = 1"),
ok = odbc:commit(Ref, rollback, ?TIMEOUT),
InsertResult = ?RDBMS:insert_result(),
- InsertResult =
+ InsertResult =
odbc:sql_query(Ref, "SELECT * FROM " ++ Table),
+ {'EXIT', {function_clause, _}} =
+ (catch odbc:commit(Ref, rollback, -1)),
- {'EXIT', {function_clause, _}} =
- (catch odbc:commit(Ref, rollback, -1)),
-
- ok = odbc:disconnect(Ref),
- ok.
+ ok = odbc:disconnect(Ref).
%%-------------------------------------------------------------------------
not_explicit_commit(doc) ->
@@ -224,20 +230,20 @@ not_explicit_commit(doc) ->
not_explicit_commit(suite) -> [];
not_explicit_commit(_Config) ->
{ok, Ref} =
- odbc:connect(?RDBMS:connection_string(), [{auto_commit, on}]),
+ odbc:connect(?RDBMS:connection_string(), [{auto_commit, on}] ++
+ odbc_test_lib:platform_options()),
{error, _} = odbc:commit(Ref, commit),
- ok = odbc:disconnect(Ref),
- ok.
+ ok = odbc:disconnect(Ref).
%%-------------------------------------------------------------------------
not_exist_db(doc) ->
["Tests valid data format but invalid data in the connection parameters."];
not_exist_db(suite) -> [];
not_exist_db(_Config) ->
- {error, _} = odbc:connect("DSN=foo;UID=bar;PWD=foobar", []),
+ {error, _} = odbc:connect("DSN=foo;UID=bar;PWD=foobar",
+ odbc_test_lib:platform_options()),
%% So that the odbc control server can be stoped "in the correct way"
- test_server:sleep(100),
- ok.
+ test_server:sleep(100).
%%-------------------------------------------------------------------------
no_c_node(doc) ->
@@ -252,7 +258,8 @@ no_c_node(_Config) ->
FileName2 = filename:nativename(filename:join(Dir, "odbcsrv")),
ok = file:rename(FileName1, FileName2),
Result =
- case catch odbc:connect(?RDBMS:connection_string(), []) of
+ case catch odbc:connect(?RDBMS:connection_string(),
+ odbc_test_lib:platform_options()) of
{error, port_program_executable_not_found} ->
ok;
Else ->
@@ -267,7 +274,7 @@ port_dies(doc) ->
"Tests what happens if the port program dies";
port_dies(suite) -> [];
port_dies(_Config) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
{status, _} = process_info(Ref, status),
process_flag(trap_exit, true),
Port = lists:last(erlang:ports()),
@@ -275,26 +282,23 @@ port_dies(_Config) ->
%% Wait for exit_status from port 5000 ms (will not get a exit
%% status in this case), then wait a little longer to make sure
%% the port and the controlprocess has had time to terminate.
- test_server:sleep(7000),
- undefined = process_info(Ref, status),
- ok.
+ test_server:sleep(10000),
+ undefined = process_info(Ref, status).
%%-------------------------------------------------------------------------
control_process_dies(doc) ->
"Tests what happens if the Erlang control process dies";
control_process_dies(suite) -> [];
control_process_dies(_Config) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
process_flag(trap_exit, true),
Port = lists:last(erlang:ports()),
{connected, Ref} = erlang:port_info(Port, connected),
exit(Ref, kill),
- test_server:sleep(100),
- undefined = erlang:port_info(Port, connected),
+ test_server:sleep(500),
+ undefined = erlang:port_info(Port, connected).
%% Check for c-program still running, how?
- ok.
-%%-------------------------------------------------------------------------
%%-------------------------------------------------------------------------
client_dies_normal(doc) ->
@@ -319,7 +323,7 @@ client_dies_normal(Config) when is_list(Config) ->
end.
client_normal(Pid) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
Pid ! {dbRef, Ref},
receive
continue ->
@@ -351,7 +355,7 @@ client_dies_timeout(Config) when is_list(Config) ->
end.
client_timeout(Pid) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
Pid ! {dbRef, Ref},
receive
continue ->
@@ -383,7 +387,7 @@ client_dies_error(Config) when is_list(Config) ->
end.
client_error(Pid) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
Pid ! {dbRef, Ref},
receive
continue ->
@@ -398,7 +402,10 @@ connect_timeout(doc) ->
connect_timeout(suite) -> [];
connect_timeout(Config) when is_list(Config) ->
{'EXIT',timeout} = (catch odbc:connect(?RDBMS:connection_string(),
- [{timeout, 0}])),
+ [{timeout, 0}] ++
+ odbc_test_lib:platform_options())),
+ %% Need to return ok here "{'EXIT',timeout} return value" will
+ %% be interpreted as that the testcase has timed out.
ok.
%%-------------------------------------------------------------------------
timeout(doc) ->
@@ -411,10 +418,12 @@ timeout(Config) when is_list(Config) ->
[{auto_commit, off}]),
Table = ?config(tableName, Config),
+ TransStr = transaction_support_str(?RDBMS),
+
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10), PRIMARY KEY(ID))"),
+ " (ID integer, DATA varchar(10), PRIMARY KEY(ID))" ++ TransStr),
{updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++ " VALUES(1,'bar')"),
@@ -446,14 +455,12 @@ timeout(Config) when is_list(Config) ->
["DATA"] = odbc_test_lib:to_upper(Fields),
ok = odbc:commit(Ref, commit),
- ok = odbc:disconnect(Ref),
- ok.
-
+ ok = odbc:disconnect(Ref).
update_table_timeout(Table, TimeOut, Pid) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
UpdateQuery = "UPDATE " ++ Table ++ " SET DATA = 'foobar' WHERE ID = 1",
case catch odbc:sql_query(Ref, UpdateQuery, TimeOut) of
@@ -474,15 +481,16 @@ update_table_timeout(Table, TimeOut, Pid) ->
odbc:sql_query(Ref, "SELECT DATA FROM " ++ Table ++ " WHERE ID = 2"),
["DATA"] = odbc_test_lib:to_upper(Fields),
- {updated, 1} = odbc:sql_query(Ref, UpdateQuery, TimeOut),
+ %% Do not check {updated, 1} as some drivers will return 0
+ %% even though the update is done, which is checked by the test
+ %% case when the altered message is recived.
+ {updated, _} = odbc:sql_query(Ref, UpdateQuery, TimeOut),
ok = odbc:commit(Ref, commit),
Pid ! altered,
- ok = odbc:disconnect(Ref),
-
- ok.
+ ok = odbc:disconnect(Ref).
%%-------------------------------------------------------------------------
many_timeouts(doc) ->
["Tests that many consecutive timeouts lead to that the connection "
@@ -490,14 +498,15 @@ many_timeouts(doc) ->
many_timeouts(suite) -> [];
many_timeouts(Config) when is_list(Config) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
+ TransStr = transaction_support_str(?RDBMS),
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10), PRIMARY KEY(ID))"),
+ " (ID integer, DATA varchar(10), PRIMARY KEY(ID))" ++ TransStr),
{updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++ " VALUES(1,'bar')"),
@@ -517,22 +526,20 @@ many_timeouts(Config) when is_list(Config) ->
end,
ok = odbc:commit(Ref, commit),
- ok = odbc:disconnect(Ref),
- ok.
+ ok = odbc:disconnect(Ref).
update_table_many_timeouts(Table, TimeOut, Pid) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
UpdateQuery = "UPDATE " ++ Table ++ " SET DATA = 'foobar' WHERE ID = 1",
ok = loop_many_timouts(Ref, UpdateQuery, TimeOut),
Pid ! many_timeouts_occurred,
- ok = odbc:disconnect(Ref),
- ok.
+ ok = odbc:disconnect(Ref).
loop_many_timouts(Ref, UpdateQuery, TimeOut) ->
@@ -546,18 +553,19 @@ loop_many_timouts(Ref, UpdateQuery, TimeOut) ->
end.
%%-------------------------------------------------------------------------
timeout_reset(doc) ->
- ["Check that the number of consecutive timouts is reset to 0 when "
+ ["Check that the number of consecutive timouts is reset to 0 when "
"a successful call to the database is made."];
timeout_reset(suite) -> [];
timeout_reset(Config) when is_list(Config) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
+ TransStr = transaction_support_str(?RDBMS),
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10), PRIMARY KEY(ID))"),
+ " (ID integer, DATA varchar(10), PRIMARY KEY(ID))" ++ TransStr),
{updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++ " VALUES(1,'bar')"),
@@ -593,13 +601,12 @@ timeout_reset(Config) when is_list(Config) ->
["DATA"] = odbc_test_lib:to_upper(Fields),
ok = odbc:commit(Ref, commit),
- ok = odbc:disconnect(Ref),
- ok.
+ ok = odbc:disconnect(Ref).
update_table_timeout_reset(Table, TimeOut, Pid) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
UpdateQuery = "UPDATE " ++ Table ++ " SET DATA = 'foobar' WHERE ID = 1",
ok = loop_timout_reset(Ref, UpdateQuery, TimeOut,
@@ -616,15 +623,16 @@ update_table_timeout_reset(Table, TimeOut, Pid) ->
odbc:sql_query(Ref, "SELECT DATA FROM " ++ Table ++ " WHERE ID = 2"),
["DATA"] = odbc_test_lib:to_upper(Fields),
- {updated,1} = odbc:sql_query(Ref, UpdateQuery, TimeOut),
+ %% Do not check {updated, 1} as some drivers will return 0
+ %% even though the update is done, which is checked by the test
+ %% case when the altered message is recived.
+ {updated, _} = odbc:sql_query(Ref, UpdateQuery, TimeOut),
ok = odbc:commit(Ref, commit),
Pid ! altered,
- ok = odbc:disconnect(Ref),
-
- ok.
+ ok = odbc:disconnect(Ref).
loop_timout_reset(_, _, _, 0) ->
ok;
@@ -648,13 +656,14 @@ disconnect_on_timeout(suite) -> [];
disconnect_on_timeout(Config) when is_list(Config) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
+ TransStr = transaction_support_str(?RDBMS),
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (ID integer, DATA varchar(10), PRIMARY KEY(ID))"),
+ " (ID integer, DATA varchar(10), PRIMARY KEY(ID))" ++ TransStr),
{updated, 1} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++ " VALUES(1,'bar')"),
@@ -678,7 +687,7 @@ disconnect_on_timeout(Config) when is_list(Config) ->
update_table_disconnect_on_timeout(Table, TimeOut, Pid) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{auto_commit, off}]),
+ [{auto_commit, off}] ++ odbc_test_lib:platform_options()),
UpdateQuery = "UPDATE " ++ Table ++ " SET DATA = 'foobar' WHERE ID = 1",
case catch odbc:sql_query(Ref, UpdateQuery, TimeOut) of
@@ -695,7 +704,7 @@ connection_closed(doc) ->
" use a connection that has been closed"];
connection_closed(suite) -> [];
connection_closed(Config) when is_list(Config) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
{updated, _} =
@@ -714,8 +723,7 @@ connection_closed(Config) when is_list(Config) ->
{error, connection_closed} = odbc:next(Ref),
{error, connection_closed} = odbc:prev(Ref),
{error, connection_closed} = odbc:select(Ref, next, 3),
- {error, connection_closed} = odbc:commit(Ref, commit),
- ok.
+ {error, connection_closed} = odbc:commit(Ref, commit).
%%-------------------------------------------------------------------------
disable_scrollable_cursors(doc) ->
@@ -753,8 +761,7 @@ disable_scrollable_cursors(Config) when is_list(Config) ->
{error, scrollable_cursors_disabled} =
odbc:select(Ref, {absolute, 2}, 5),
- {selected, _ColNames,[]} = odbc:select(Ref, next, 1),
- ok.
+ {selected, _ColNames,[]} = odbc:select(Ref, next, 1).
%%-------------------------------------------------------------------------
return_rows_as_lists(doc)->
@@ -763,7 +770,7 @@ return_rows_as_lists(doc)->
return_rows_as_lists(suite) -> [];
return_rows_as_lists(Config) when is_list(Config) ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{tuple_row, off}]),
+ [{tuple_row, off}] ++ odbc_test_lib:platform_options()),
Table = ?config(tableName, Config),
@@ -784,16 +791,21 @@ return_rows_as_lists(Config) when is_list(Config) ->
{ok, _} = odbc:select_count(Ref, "SELECT * FROM " ++ Table),
- First = ?RDBMS:first_list_rows(),
- Last = ?RDBMS:last_list_rows(),
- Prev = ?RDBMS:prev_list_rows(),
- Next = ?RDBMS:next_list_rows(),
-
- Last = odbc:last(Ref),
- Prev = odbc:prev(Ref),
- First = odbc:first(Ref),
- Next = odbc:next(Ref),
- ok.
+ case proplists:get_value(scrollable_cursors, odbc_test_lib:platform_options()) of
+ off ->
+ Next = ?RDBMS:next_list_rows(),
+ Next = odbc:next(Ref);
+ _ ->
+ First = ?RDBMS:first_list_rows(),
+ Last = ?RDBMS:last_list_rows(),
+ Prev = ?RDBMS:prev_list_rows(),
+ Next = ?RDBMS:next_list_rows(),
+
+ Last = odbc:last(Ref),
+ Prev = odbc:prev(Ref),
+ First = odbc:first(Ref),
+ Next = odbc:next(Ref)
+ end.
%%-------------------------------------------------------------------------
@@ -802,22 +814,27 @@ api_missuse(doc)->
api_missuse(suite) -> [];
api_missuse(Config) when is_list(Config)->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
%% Serious programming fault, connetion will be shut down
gen_server:call(Ref, {self(), foobar, 10}, infinity),
test_server:sleep(10),
undefined = process_info(Ref, status),
- {ok, Ref2} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref2} = odbc:connect(?RDBMS:connection_string(),
+ odbc_test_lib:platform_options()),
%% Serious programming fault, connetion will be shut down
gen_server:cast(Ref2, {self(), foobar, 10}),
test_server:sleep(10),
undefined = process_info(Ref2, status),
- {ok, Ref3} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref3} = odbc:connect(?RDBMS:connection_string(),
+ odbc_test_lib:platform_options()),
%% Could be an innocent misstake the connection lives.
Ref3 ! foobar,
test_server:sleep(10),
- {status, _} = process_info(Ref3, status),
- ok.
+ {status, _} = process_info(Ref3, status).
+transaction_support_str(mysql) ->
+ "ENGINE = InnoDB";
+transaction_support_str(_) ->
+ "".
diff --git a/lib/odbc/test/odbc_data_type_SUITE.erl b/lib/odbc/test/odbc_data_type_SUITE.erl
index bfb1e4b329..d61a91f973 100644
--- a/lib/odbc/test/odbc_data_type_SUITE.erl
+++ b/lib/odbc/test/odbc_data_type_SUITE.erl
@@ -44,24 +44,29 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
case odbc_test_lib:odbc_check() of
ok ->
- [{group, char}, {group, int}, {group, floats},
+ [{group, char},{group, fixed_char}, {group, binary_char},
+ {group, fixed_binary_char}, {group, unicode},
+ {group, int}, {group, floats},
{group, dec_and_num}, timestamp];
Other -> {skip, Other}
end.
groups() ->
[{char, [],
- [char_fixed_lower_limit, char_fixed_upper_limit,
- char_fixed_padding, varchar_lower_limit,
+ [varchar_lower_limit,
varchar_upper_limit, varchar_no_padding,
- text_lower_limit, text_upper_limit, unicode]},
+ text_lower_limit, text_upper_limit]},
+ {fixed_char, [],
+ [char_fixed_lower_limit, char_fixed_upper_limit,
+ char_fixed_padding]},
{binary_char, [],
- [binary_char_fixed_lower_limit,
- binary_char_fixed_upper_limit,
- binary_char_fixed_padding, binary_varchar_lower_limit,
+ [binary_varchar_lower_limit,
binary_varchar_upper_limit, binary_varchar_no_padding,
- binary_text_lower_limit, binary_text_upper_limit,
- unicode]},
+ binary_text_lower_limit, binary_text_upper_limit]},
+ {fixed_binary_char, [], [binary_char_fixed_lower_limit,
+ binary_char_fixed_upper_limit,
+ binary_char_fixed_padding]},
+ {unicode, [], [utf8, nchar, nvarchar]},
{int, [],
[tiny_int_lower_limit, tiny_int_upper_limit,
small_int_lower_limit, small_int_upper_limit,
@@ -74,14 +79,31 @@ groups() ->
[dec_long, dec_double, dec_bignum, num_long, num_double,
num_bignum]}].
+init_per_group(GroupName, Config) when GroupName == fixed_char;
+ GroupName == fixed_binary_char ->
+ case ?RDBMS of
+ mysql ->
+ {skip, "No supported by MYSQL"};
+ _ ->
+ Config
+ end;
+
+init_per_group(unicode, Config) ->
+ case {os:type(), erlang:system_info({wordsize, external})} of
+ {{unix, _}, 4} ->
+ Config;
+ {{unix, _}, _} ->
+ {skip, "Postgres drivers pre version psqlODBC 08.04.0200 have utf8-problems"};
+ _ ->
+ Config
+ end;
+
init_per_group(_GroupName, Config) ->
Config.
end_per_group(_GroupName, Config) ->
Config.
-
-
%%--------------------------------------------------------------------
%% Function: init_per_suite(Config) -> Config
%% Config - [tuple()]
@@ -91,10 +113,18 @@ end_per_group(_GroupName, Config) ->
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
-init_per_suite(Config) ->
- application:start(odbc),
- [{tableName, odbc_test_lib:unique_table_name()} | Config].
-
+init_per_suite(Config) when is_list(Config) ->
+ case odbc_test_lib:skip() of
+ true ->
+ {skip, "ODBC not supported"};
+ false ->
+ case (catch odbc:start()) of
+ ok ->
+ [{tableName, odbc_test_lib:unique_table_name()}| Config];
+ _ ->
+ {skip, "ODBC not startable"}
+ end
+ end.
%%--------------------------------------------------------------------
%% Function: end_per_suite(Config) -> _
%% Config - [tuple()]
@@ -117,22 +147,81 @@ end_per_suite(_Config) ->
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
+init_per_testcase(Case, Config) when Case == varchar_upper_limit;
+ Case == binary_varchar_upper_limit;
+ Case == varchar_no_padding;
+ Case == binary_varchar_no_padding ->
+ case is_fixed_upper_limit(?RDBMS) of
+ true ->
+ common_init_per_testcase(Case, Config);
+ false ->
+ {skip, "Upper limit is not fixed in" ++ atom_to_list(?RDBMS)}
+ end;
+
+init_per_testcase(text_upper_limit, _Config) ->
+ {skip, "Consumes too much resources"};
+
+init_per_testcase(Case, Config) when Case == bit_true; Case == bit_false ->
+ case is_supported_bit(?RDBMS) of
+ true ->
+ common_init_per_testcase(Case, Config);
+ false ->
+ {skip, "Not supported by driver"}
+ end;
+
+init_per_testcase(param_insert_tiny_int = Case, Config) ->
+ case is_supported_tinyint(?RDBMS) of
+ true ->
+ common_init_per_testcase(Case, Config);
+ false ->
+ {skip, "Not supported by driver"}
+ end;
+
+init_per_testcase(Case, Config) when Case == nchar;
+ Case == nvarchar ->
+ case ?RDBMS of
+ sqlserver ->
+ common_init_per_testcase(Case, Config);
+ _ ->
+ {skip, "Not supported by driver"}
+ end;
+
init_per_testcase(Case, Config) ->
+ common_init_per_testcase(Case, Config).
+
+common_init_per_testcase(Case, Config) ->
+ PlatformOptions = odbc_test_lib:platform_options(),
case atom_to_list(Case) of
"binary" ++ _ ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{binary_strings, on}]);
- "unicode" ->
+ [{binary_strings, on}] ++ PlatformOptions);
+ LCase when LCase == "utf8";
+ LCase == "nchar";
+ LCase == "nvarchar" ->
{ok, Ref} = odbc:connect(?RDBMS:connection_string(),
- [{binary_strings, on}]);
+ [{binary_strings, on}] ++ PlatformOptions);
_ ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), [])
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), PlatformOptions)
end,
+ odbc_test_lib:strict(Ref, ?RDBMS),
Dog = test_server:timetrap(?default_timeout),
Temp = lists:keydelete(connection_ref, 1, Config),
NewConfig = lists:keydelete(watchdog, 1, Temp),
[{watchdog, Dog}, {connection_ref, Ref} | NewConfig].
+is_fixed_upper_limit(mysql) ->
+ false;
+is_fixed_upper_limit(_) ->
+ true.
+is_supported_tinyint(sqlserver) ->
+ true;
+is_supported_tinyint(_) ->
+ false.
+is_supported_bit(sqlserver) ->
+ true;
+is_supported_bit(_) ->
+ false.
+
%%--------------------------------------------------------------------
%% Function: end_per_testcase(Case, Config) -> _
%% Case - atom()
@@ -146,7 +235,7 @@ end_per_testcase(_TestCase, Config) ->
ok = odbc:disconnect(Ref),
%% Clean up if needed
Table = ?config(tableName, Config),
- {ok, NewRef} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, NewRef} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
odbc:sql_query(NewRef, "DROP TABLE " ++ Table),
odbc:disconnect(NewRef),
Dog = ?config(watchdog, Config),
@@ -169,18 +258,18 @@ char_fixed_lower_limit(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- ?RDBMS:create_fixed_char_table(
+ ?RDBMS:create_fixed_char_table(
(?RDBMS:fixed_char_min() - 1))),
%% Lower limit
{updated, _} = % Value == 0 || -1 driver dependent!
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_fixed_char_table(
- ?RDBMS:fixed_char_min())),
+ ?RDBMS:create_fixed_char_table(
+ ?RDBMS:fixed_char_min())),
%% Right length data
{updated, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a, ?RDBMS:fixed_char_min())
+ "'" ++ string:chars($a, ?RDBMS:fixed_char_min())
++ "')"),
%% Select data
{selected, Fields,[{"a"}]} =
@@ -191,11 +280,11 @@ char_fixed_lower_limit(Config) when is_list(Config) ->
%% Too long data
{error, _} =
odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a,
- (?RDBMS:fixed_char_min()
- + 1))
- ++ "')"),
- ok.
+ "'" ++ string:chars($a,
+ (?RDBMS:fixed_char_min()
+ + 1))
+ ++ "')").
+
%%-------------------------------------------------------------------------
char_fixed_upper_limit(doc) ->
@@ -243,8 +332,7 @@ char_fixed_upper_limit(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
?RDBMS:create_fixed_char_table(
- (?RDBMS:fixed_char_max() + 1))),
- ok
+ (?RDBMS:fixed_char_max() + 1)))
end.
%%-------------------------------------------------------------------------
@@ -261,20 +349,20 @@ char_fixed_padding(Config) when is_list(Config) ->
%% Data should be padded with blanks
{updated, _} = % Value == 0 || -1 driver dependent!
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_fixed_char_table(
- ?RDBMS:fixed_char_max())),
+ ?RDBMS:create_fixed_char_table(
+ ?RDBMS:fixed_char_max())),
- {updated, _} =
+ {updated, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a,
- ?RDBMS:fixed_char_min())
+ "'" ++ string:chars($a,
+ ?RDBMS:fixed_char_min())
++ "')"),
{selected, Fields, [{CharStr}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
true = length(CharStr) == ?RDBMS:fixed_char_max(),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
+
%%-------------------------------------------------------------------------
varchar_lower_limit(doc) ->
@@ -287,33 +375,33 @@ varchar_lower_limit(Config) when is_list(Config) ->
%% Below limit
{error, _} =
- odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_var_char_table(
- ?RDBMS:var_char_min() - 1)),
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
+ ?RDBMS:create_var_char_table(
+ ?RDBMS:var_char_min() - 1)),
%% Lower limit
{updated, _} = % Value == 0 || -1 driver dependent!
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_var_char_table(
- ?RDBMS:var_char_min())),
+ ?RDBMS:create_var_char_table(
+ ?RDBMS:var_char_min())),
+
+ Str = string:chars($a, ?RDBMS:var_char_min()),
%% Right length data
{updated, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a, ?RDBMS:var_char_min())
- ++ "')"),
+ "'" ++ Str ++ "')"),
%% Select data
- {selected, Fields, [{"a"}]} =
+ {selected, Fields, [{Str}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
["FIELD"] = odbc_test_lib:to_upper(Fields),
- %% Too long data
- {error, _} =
- odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a,
- (?RDBMS:var_char_min()+1))
- ++ "')"),
- ok.
+ %% Too long datae
+ {error, _} =
+ odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
+ "'" ++ string:chars($a,
+ (?RDBMS:var_char_min()+1))
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -389,8 +477,7 @@ varchar_no_padding(Config) when is_list(Config) ->
{selected, Fields, [{CharStr}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
true = length(CharStr) /= ?RDBMS:var_char_max(),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%-------------------------------------------------------------------------
@@ -413,8 +500,7 @@ text_lower_limit(Config) when is_list(Config) ->
{selected, Fields, [{"a"}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%-------------------------------------------------------------------------
@@ -444,8 +530,7 @@ text_upper_limit(Config) when is_list(Config) ->
%% {error, _} =
%% odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
%% "'" ++ string:chars($a, (?RDBMS:text_max()+1))
-%% ++ "')"),
-%% ok.
+%% ++ "')").
%%-------------------------------------------------------------------------
@@ -469,13 +554,18 @@ binary_char_fixed_lower_limit(Config) when is_list(Config) ->
?RDBMS:create_fixed_char_table(
?RDBMS:fixed_char_min())),
+ Str = string:chars($a, ?RDBMS:fixed_char_min()),
+
%% Right length data
{updated, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a, ?RDBMS:fixed_char_min())
+ "'" ++ Str
++ "')"),
+
+ Bin = list_to_binary(Str),
+
%% Select data
- {selected, Fields,[{<<"a">>}]} =
+ {selected, Fields,[{Bin}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
["FIELD"] = odbc_test_lib:to_upper(Fields),
@@ -486,8 +576,7 @@ binary_char_fixed_lower_limit(Config) when is_list(Config) ->
"'" ++ string:chars($a,
(?RDBMS:fixed_char_min()
+ 1))
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
binary_char_fixed_upper_limit(doc) ->
@@ -565,8 +654,8 @@ binary_char_fixed_padding(Config) when is_list(Config) ->
{selected, Fields, [{CharBin}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
true = size(CharBin) == ?RDBMS:fixed_char_max(),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
+
%%-------------------------------------------------------------------------
binary_varchar_lower_limit(doc) ->
@@ -588,13 +677,17 @@ binary_varchar_lower_limit(Config) when is_list(Config) ->
?RDBMS:create_var_char_table(
?RDBMS:var_char_min())),
+ Str = string:chars($a, ?RDBMS:var_char_min()),
+
%% Right length data
{updated, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ string:chars($a, ?RDBMS:var_char_min())
+ "'" ++ Str
++ "')"),
+ BinStr = list_to_binary(Str),
+
%% Select data
- {selected, Fields, [{<<"a">>}]} =
+ {selected, Fields, [{BinStr}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
["FIELD"] = odbc_test_lib:to_upper(Fields),
@@ -604,8 +697,7 @@ binary_varchar_lower_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ string:chars($a,
(?RDBMS:var_char_min()+1))
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -654,8 +746,7 @@ binary_varchar_upper_limit(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
?RDBMS:create_var_char_table(
- (?RDBMS:var_char_max() + 1))),
- ok
+ (?RDBMS:var_char_max() + 1)))
end.
%%-------------------------------------------------------------------------
@@ -681,8 +772,7 @@ binary_varchar_no_padding(Config) when is_list(Config) ->
{selected, Fields, [{CharBin}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
true = size(CharBin) /= ?RDBMS:var_char_max(),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%-------------------------------------------------------------------------
@@ -705,8 +795,7 @@ binary_text_lower_limit(Config) when is_list(Config) ->
{selected, Fields, [{<<"a">>}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%-------------------------------------------------------------------------
@@ -736,11 +825,7 @@ binary_text_upper_limit(Config) when is_list(Config) ->
%% {error, _} =
%% odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
%% "'" ++ string:chars($a, (?RDBMS:text_max()+1))
-%% ++ "')"),
-%% ok.
-
-
-%%-------------------------------------------------------------------------
+%% ++ "')").
%%-------------------------------------------------------------------------
@@ -774,8 +859,7 @@ tiny_int_lower_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:tiny_int_min()
- 1)
- ++ "')"),
- ok
+ ++ "')")
end.
%%-------------------------------------------------------------------------
@@ -809,8 +893,7 @@ tiny_int_upper_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:tiny_int_max()
+ 1)
- ++ "')"),
- ok
+ ++ "')")
end.
%%-------------------------------------------------------------------------
@@ -840,8 +923,7 @@ small_int_lower_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:small_int_min()
- 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -870,8 +952,7 @@ small_int_upper_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:small_int_max()
+ 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
int_lower_limit(doc) ->
@@ -898,8 +979,7 @@ int_lower_limit(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:int_min() - 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -927,8 +1007,7 @@ int_upper_limit(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:int_max() + 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -957,8 +1036,7 @@ big_int_lower_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:big_int_min()
- 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
@@ -987,8 +1065,7 @@ big_int_upper_limit(Config) when is_list(Config) ->
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(?RDBMS:big_int_max()
+ 1)
- ++ "')"),
- ok.
+ ++ "')").
%%-------------------------------------------------------------------------
bit_false(doc) ->
@@ -1020,8 +1097,7 @@ bit_false(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(-1)
- ++ "')"),
- ok
+ ++ "')")
end.
%%-------------------------------------------------------------------------
@@ -1056,14 +1132,10 @@ bit_true(Config) when is_list(Config) ->
{error, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
"'" ++ integer_to_list(-1)
- ++ "')"),
- ok
+ ++ "')")
end.
%%-------------------------------------------------------------------------
-
-
-%%-------------------------------------------------------------------------
float_lower_limit(doc) ->
[""];
float_lower_limit(suite) ->
@@ -1073,44 +1145,45 @@ float_lower_limit(Config) when is_list(Config) ->
Ref = ?config(connection_ref, Config),
Table = ?config(tableName, Config),
- {updated, _} = % Value == 0 || -1 driver dependent!
- odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_float_table()),
-
- {updated, _} =
- odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ float_to_list(
- ?RDBMS:float_min())
- ++ "')"),
- {selected,[_ColName],[{MinFloat}]} =
- odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
-
- true = ?RDBMS:float_min() == MinFloat,
-
case ?RDBMS of
- oracle ->
- {updated, _} = % Value == 0 || -1 driver dependent!
- odbc:sql_query(Ref, "DROP TABLE " ++ Table),
-
+ mysql ->
+ {skip, "Not clearly defined in MYSQL"};
+ _ ->
{updated, _} = % Value == 0 || -1 driver dependent!
odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_float_table()),
+ ?RDBMS:create_float_table()),
{updated, _} =
- odbc:sql_query(Ref,
- "INSERT INTO " ++ Table ++" VALUES(" ++
- ?RDBMS:float_underflow() ++ ")"),
-
- SelectResult = ?RDBMS:float_zero_selected(),
- SelectResult =
- odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table);
- _ ->
- {error, _} =
odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- ?RDBMS:float_underflow() ++ ")")
- end,
- ok.
+ "'" ++ float_to_list(
+ ?RDBMS:float_min())
+ ++ "')"),
+ {selected,[_ColName],[{MinFloat}]} =
+ odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
+ true = ?RDBMS:float_min() == MinFloat,
+
+ case ?RDBMS of
+ oracle ->
+ {updated, _} = % Value == 0 || -1 driver dependent!
+ odbc:sql_query(Ref, "DROP TABLE " ++ Table),
+
+ {updated, _} = % Value == 0 || -1 driver dependent!
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
+ ?RDBMS:create_float_table()),
+ {updated, _} =
+ odbc:sql_query(Ref,
+ "INSERT INTO " ++ Table ++" VALUES(" ++
+ ?RDBMS:float_underflow() ++ ")"),
+ SelectResult = ?RDBMS:float_zero_selected(),
+ SelectResult =
+ odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table);
+ _ ->
+ {error, _} =
+ odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
+ ?RDBMS:float_underflow() ++ ")")
+ end
+ end.
%%-------------------------------------------------------------------------
float_upper_limit(doc) ->
@@ -1121,26 +1194,28 @@ float_upper_limit(Config) when is_list(Config) ->
Ref = ?config(connection_ref, Config),
Table = ?config(tableName, Config),
- {updated, _} = % Value == 0 || -1 driver dependent!
- odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_float_table()),
-
- {updated, _} =
- odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- "'" ++ float_to_list(
- ?RDBMS:float_max())
- ++ "')"),
-
+ case ?RDBMS of
+ mysql ->
+ {skip, "Not clearly defined in MYSQL"};
+ _->
+ {updated, _} = % Value == 0 || -1 driver dependent!
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
+ ?RDBMS:create_float_table()),
- {selected,[_ColName],[{MaxFloat}]}
- = odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
+ {updated, _} =
+ odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
+ "'" ++ float_to_list(
+ ?RDBMS:float_max())
+ ++ "')"),
+ {selected,[_ColName],[{MaxFloat}]}
+ = odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- true = ?RDBMS:float_max() == MaxFloat,
+ true = ?RDBMS:float_max() == MaxFloat,
- {error, _} =
- odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
- ?RDBMS:float_overflow() ++ ")"),
- ok.
+ {error, _} =
+ odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
+ ?RDBMS:float_overflow() ++ ")")
+ end.
%%-------------------------------------------------------------------------
float_zero(doc) ->
@@ -1160,8 +1235,7 @@ float_zero(Config) when is_list(Config) ->
SelectResult = ?RDBMS:float_zero_selected(),
SelectResult =
- odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ok.
+ odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table).
%%-------------------------------------------------------------------------
real_zero(doc) ->
["Test the real value zero."];
@@ -1185,10 +1259,8 @@ real_zero(Config) when is_list(Config) ->
SelectResult = ?RDBMS:real_zero_selected(),
SelectResult =
- odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ok
+ odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table)
end.
-%%-------------------------------------------------------------------------
%%------------------------------------------------------------------------
dec_long(doc) ->
[""];
@@ -1207,8 +1279,7 @@ dec_long(Config) when is_list(Config) ->
{selected, Fields, [{2}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%------------------------------------------------------------------------
dec_double(doc) ->
[""];
@@ -1255,8 +1326,7 @@ dec_double(Config) when is_list(Config) ->
{selected, Fields2, [{1.60000}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields2),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields2).
%%------------------------------------------------------------------------
dec_bignum(doc) ->
@@ -1289,8 +1359,7 @@ dec_bignum(Config) when is_list(Config) ->
{selected, Fields1, [{"1.6"}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields1),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields1).
%%------------------------------------------------------------------------
num_long(doc) ->
[""];
@@ -1309,8 +1378,7 @@ num_long(Config) when is_list(Config) ->
{selected, Fields, [{2}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields).
%%------------------------------------------------------------------------
num_double(doc) ->
[""];
@@ -1356,8 +1424,7 @@ num_double(Config) when is_list(Config) ->
{selected, Fields2, [{1.6000}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields2),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields2).
%%------------------------------------------------------------------------
num_bignum(doc) ->
[""];
@@ -1389,21 +1456,19 @@ num_bignum(Config) when is_list(Config) ->
{selected, Fields1, [{"1.6"}]} =
odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
- ["FIELD"] = odbc_test_lib:to_upper(Fields1),
- ok.
+ ["FIELD"] = odbc_test_lib:to_upper(Fields1).
%%------------------------------------------------------------------------
-unicode(doc) ->
+utf8(doc) ->
["Test unicode support"];
-unicode(suit) ->
+utf8(suit) ->
[];
-unicode(Config) when is_list(Config) ->
+utf8(Config) when is_list(Config) ->
Ref = ?config(connection_ref, Config),
Table = ?config(tableName, Config),
- {updated, _} = % Value == 0 || -1 driver dependent!
- odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
- ?RDBMS:create_unicode_table()),
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++ "(FIELD text)"),
+
Latin1Data = ["���������",
"testasdf",
"Row 3",
@@ -1416,39 +1481,7 @@ unicode(Config) when is_list(Config) ->
"Row 10",
"Row 11",
"Row 12"],
-
- case ?RDBMS of
- sqlserver ->
- w_char_support_win(Ref, Table, Latin1Data);
- postgres ->
- direct_utf8(Ref, Table, Latin1Data);
- oracle ->
- {skip, "not currently supported"}
- end.
-
-w_char_support_win(Ref, Table, Latin1Data) ->
- UnicodeIn = lists:map(fun(S) ->
- unicode:characters_to_binary(S,latin1,{utf16,little})
- end,
- Latin1Data),
-
- test_server:format("UnicodeIn (utf 16): ~p ~n",[UnicodeIn]),
- {updated, _} = odbc:param_query(Ref, "INSERT INTO " ++ Table ++ "(FIELD) values(?)",
- [{{sql_wvarchar,50},UnicodeIn}]),
-
- {selected,_,UnicodeOut} = odbc:sql_query(Ref,"SELECT * FROM " ++ Table),
-
- test_server:format("UnicodeOut: ~p~n", [UnicodeOut]),
-
- Result = lists:map(fun({Unicode}) ->
- unicode:characters_to_list(Unicode,{utf16,little})
- end,
- UnicodeOut),
- Latin1Data = Result.
-
-
-direct_utf8(Ref, Table, Latin1Data) ->
UnicodeIn = lists:map(fun(String) ->
unicode:characters_to_binary(String,latin1,utf8)
end,
@@ -1469,6 +1502,37 @@ direct_utf8(Ref, Table, Latin1Data) ->
test_server:format("Result: ~p ~n", [Result]),
Latin1Data = Result.
+%%------------------------------------------------------------------------
+
+nchar(doc) ->
+ ["Test unicode nchar support in sqlserver"];
+nchar(suit) ->
+ [];
+nchar(Config) when is_list(Config) ->
+ Ref = ?config(connection_ref, Config),
+ Table = ?config(tableName, Config),
+
+ {updated, _} = % Value == 0 || -1 driver dependent!
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
+ "(FIELD nchar(50))"),
+
+ w_char_support(Ref, Table, sql_wvarchar, 50).
+
+%%------------------------------------------------------------------------
+
+nvarchar(doc) ->
+ ["Test 'unicode' nvarchar support"];
+nvarchar(suit) ->
+ [];
+nvarchar(Config) when is_list(Config) ->
+ Ref = ?config(connection_ref, Config),
+ Table = ?config(tableName, Config),
+
+ {updated, _} = % Value == 0 || -1 driver dependent!
+ odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++
+ "(FIELD nvarchar(50))"),
+
+ w_char_support(Ref, Table, sql_wlongvarchar, 50).
%%------------------------------------------------------------------------
timestamp(doc) ->
@@ -1497,3 +1561,43 @@ timestamp(Config) when is_list(Config) ->
TimeStamps = lists:map(fun(Value) -> {Value} end, Data),
{selected,_, TimeStamps} = odbc:sql_query(Ref, "SELECT * FROM " ++ Table).
+%%------------------------------------------------------------------------
+
+w_char_support(Ref, Table, CharType, Size) ->
+ Latin1Data = ["���������",
+ "testasdf",
+ "Row 3",
+ "Row 4",
+ "Row 5",
+ "Row 6",
+ "Row 7",
+ "Row 8",
+ "Row 9",
+ "Row 10",
+ "Row 11",
+ "Row 12"],
+
+ UnicodeIn = lists:map(fun(S) ->
+ unicode:characters_to_binary(S,latin1,{utf16,little})
+ end,
+ Latin1Data),
+
+ test_server:format("UnicodeIn (utf 16): ~p ~n",[UnicodeIn]),
+
+ {updated, _} = odbc:param_query(Ref, "INSERT INTO " ++ Table ++ "(FIELD) values(?)",
+ [{{CharType, Size},UnicodeIn}]),
+
+ {selected,_,UnicodeOut} = odbc:sql_query(Ref,"SELECT * FROM " ++ Table),
+
+ test_server:format("UnicodeOut: ~p~n", [UnicodeOut]),
+
+ PadResult = lists:map(fun({Unicode}) ->
+ unicode:characters_to_list(Unicode,{utf16,little})
+ end,
+ UnicodeOut),
+
+ test_server:format("Result: ~p~n", [PadResult]),
+
+ Result = lists:map(fun(Str) -> string:strip(Str) end, PadResult),
+
+ Latin1Data = Result.
diff --git a/lib/odbc/test/odbc_query_SUITE.erl b/lib/odbc/test/odbc_query_SUITE.erl
index 8b8d1e7a40..1852678b4b 100644
--- a/lib/odbc/test/odbc_query_SUITE.erl
+++ b/lib/odbc/test/odbc_query_SUITE.erl
@@ -43,19 +43,22 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
case odbc_test_lib:odbc_check() of
ok ->
- [sql_query, first, last, next, prev, select_count,
+ [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,
- multiple_select_result_sets, multiple_mix_result_sets,
- multiple_result_sets_error,
+ {group, multiple_result_sets},
{group, parameterized_queries}, {group, describe_table},
delete_nonexisting_row];
Other -> {skip, Other}
end.
groups() ->
- [{parameterized_queries, [],
+ [{multiple_result_sets, [], [multiple_select_result_sets,
+ multiple_mix_result_sets,
+ multiple_result_sets_error]},
+ {scrollable_cursors, [], [first, last, prev]},
+ {parameterized_queries, [],
[{group, param_integers}, param_insert_decimal,
param_insert_numeric, {group, param_insert_string},
param_insert_float, param_insert_real,
@@ -72,15 +75,27 @@ groups() ->
[describe_integer, describe_string, describe_floating,
describe_dec_num, describe_no_such_table]}].
-init_per_group(_GroupName, Config) ->
+init_per_group(multiple_result_sets, Config) ->
+ case is_supported_multiple_resultsets(?RDBMS) of
+ true ->
+ Config;
+ false ->
+ {skip, "Not supported by " ++ atom_to_list(?RDBMS) ++ "driver"}
+ end;
+init_per_group(scrollable_cursors, Config) ->
+ case proplists:get_value(scrollable_cursors, odbc_test_lib:platform_options()) of
+ off ->
+ {skip, "Not supported by driver"};
+ _ ->
+ Config
+ end;
+
+init_per_group(_,Config) ->
Config.
end_per_group(_GroupName, Config) ->
Config.
-
-
-
%%--------------------------------------------------------------------
%% Function: init_per_suite(Config) -> Config
%% Config - [tuple()]
@@ -91,8 +106,17 @@ end_per_group(_GroupName, Config) ->
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_suite(Config) when is_list(Config) ->
- application:start(odbc),
- [{tableName, odbc_test_lib:unique_table_name()}| Config].
+ case odbc_test_lib:skip() of
+ true ->
+ {skip, "ODBC not supported"};
+ false ->
+ case (catch odbc:start()) of
+ ok ->
+ [{tableName, odbc_test_lib:unique_table_name()}| Config];
+ _ ->
+ {skip, "ODBC not startable"}
+ end
+ end.
%%--------------------------------------------------------------------
%% Function: end_per_suite(Config) -> _
@@ -117,7 +141,8 @@ end_per_suite(_Config) ->
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_testcase(_Case, Config) ->
- {ok, Ref} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
+ odbc_test_lib:strict(Ref, ?RDBMS),
Dog = test_server:timetrap(?default_timeout),
Temp = lists:keydelete(connection_ref, 1, Config),
NewConfig = lists:keydelete(watchdog, 1, Temp),
@@ -136,7 +161,7 @@ end_per_testcase(_Case, Config) ->
ok = odbc:disconnect(Ref),
%% Clean up if needed
Table = ?config(tableName, Config),
- {ok, NewRef} = odbc:connect(?RDBMS:connection_string(), []),
+ {ok, NewRef} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
odbc:sql_query(NewRef, "DROP TABLE " ++ Table),
odbc:disconnect(NewRef),
Dog = ?config(watchdog, Config),
@@ -663,9 +688,6 @@ multiple_result_sets_error(Config) when is_list(Config) ->
end.
%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
-%%-------------------------------------------------------------------------
param_insert_tiny_int(doc)->
["Test insertion of tiny ints by parameterized queries."];
param_insert_tiny_int(suite) ->
@@ -901,8 +923,6 @@ param_insert_numeric(Config) when is_list(Config) ->
ok.
%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
param_insert_char(doc)->
["Test insertion of fixed length string by parameterized queries."];
param_insert_char(suite) ->
@@ -1325,8 +1345,6 @@ param_select(Config) when is_list(Config) ->
ok.
%%-------------------------------------------------------------------------
-
-%%-------------------------------------------------------------------------
describe_integer(doc) ->
["Test describe_table/[2,3] for integer columns."];
describe_integer(suite) ->
@@ -1338,7 +1356,7 @@ describe_integer(Config) when is_list(Config) ->
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (int1 SMALLINT, int2 INT, int3 INTEGER)"),
+ " (myint1 SMALLINT, myint2 INT, myint3 INTEGER)"),
Decs = ?RDBMS:describe_integer(),
%% Make sure to test timeout clause
@@ -1399,7 +1417,7 @@ describe_dec_num(Config) when is_list(Config) ->
{updated, _} =
odbc:sql_query(Ref,
"CREATE TABLE " ++ Table ++
- " (dec DECIMAL(9,3), num NUMERIC(9,2))"),
+ " (mydec DECIMAL(9,3), mynum NUMERIC(9,2))"),
Decs = ?RDBMS:describe_dec_num(),
@@ -1451,3 +1469,7 @@ is_driver_error(Error) ->
false ->
test_server:fail(Error)
end.
+is_supported_multiple_resultsets(sqlserver) ->
+ true;
+is_supported_multiple_resultsets(_) ->
+ false.
diff --git a/lib/odbc/test/odbc_start_SUITE.erl b/lib/odbc/test/odbc_start_SUITE.erl
index 65b990133f..e3a3440559 100644
--- a/lib/odbc/test/odbc_start_SUITE.erl
+++ b/lib/odbc/test/odbc_start_SUITE.erl
@@ -39,11 +39,18 @@
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_suite(Config) ->
- case code:which(odbc) of
- non_existing ->
- {skip, "No ODBC built"};
- _ ->
- [{tableName, odbc_test_lib:unique_table_name()} | Config]
+ case odbc_test_lib:skip() of
+ true ->
+ {skip, "ODBC not supported"};
+ false ->
+ case code:which(odbc) of
+ non_existing ->
+ {skip, "No ODBC built"};
+ _ ->
+ %% Make sure odbc is not already started
+ odbc:stop(),
+ [{tableName, odbc_test_lib:unique_table_name()} | Config]
+ end
end.
%%--------------------------------------------------------------------
@@ -125,14 +132,16 @@ start(doc) ->
start(suite) ->
[];
start(Config) when is_list(Config) ->
- {error,odbc_not_started} = odbc:connect(?RDBMS:connection_string(), []),
+ PlatformOptions = odbc_test_lib:platform_options(),
+ {error,odbc_not_started} = odbc:connect(?RDBMS:connection_string(),
+ PlatformOptions),
odbc:start(),
- case odbc:connect(?RDBMS:connection_string(), []) of
+ case odbc:connect(?RDBMS:connection_string(), PlatformOptions) of
{ok, Ref0} ->
ok = odbc:disconnect(Ref0),
odbc:stop(),
{error,odbc_not_started} =
- odbc:connect(?RDBMS:connection_string(), []),
+ odbc:connect(?RDBMS:connection_string(), PlatformOptions),
start_odbc(transient),
start_odbc(permanent);
{error, odbc_not_started} ->
@@ -144,7 +153,7 @@ start(Config) when is_list(Config) ->
start_odbc(Type) ->
ok = odbc:start(Type),
- case odbc:connect(?RDBMS:connection_string(), []) of
+ case odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()) of
{ok, Ref} ->
ok = odbc:disconnect(Ref),
odbc:stop();
diff --git a/lib/odbc/test/odbc_test.hrl b/lib/odbc/test/odbc_test.hrl
index 87f50043db..f7bb338a7f 100644
--- a/lib/odbc/test/odbc_test.hrl
+++ b/lib/odbc/test/odbc_test.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -25,9 +25,16 @@
-define(RDBMS, case os:type() of
{unix, sunos} ->
- postgres;
+ mysql;
{unix,linux} ->
- postgres;
+ case erlang:system_info({wordsize, external}) of
+ 4 ->
+ mysql;
+ _ ->
+ postgres
+ end;
+ {unix, darwin} ->
+ mysql;
{win32, _} ->
sqlserver
end).
diff --git a/lib/odbc/test/odbc_test_lib.erl b/lib/odbc/test/odbc_test_lib.erl
index 012eb96e43..a8439d5fb6 100644
--- a/lib/odbc/test/odbc_test_lib.erl
+++ b/lib/odbc/test/odbc_test_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -36,29 +36,25 @@ match_float(Float, Match, Delta) ->
(Float < Match + Delta) and (Float > Match - Delta).
odbc_check() ->
- case erlang:system_info(wordsize) of
- 4 ->
- case test_server:os_type() of
- {unix, sunos} ->
- ok;
- {unix, linux} ->
- ok;
- {win32, _} ->
+ case os:type() of
+ {unix,darwin} ->
+ lists:flatten(
+ io_lib:format("Currently we have no working drivers for MAC",
+ []));
+ _ ->
+ case erlang:system_info({wordsize, external}) of
+ 4 ->
ok;
Other ->
- lists:flatten(
- io_lib:format("Platform not supported: ~w",
- [Other]))
- end;
- Other ->
- case os:type() of
- {unix, linux} ->
- ok;
- Platform ->
- lists:flatten(
- io_lib:format("Word on platform ~w size"
- " ~w not supported", [Other,
- Platform]))
+ case os:type() of
+ {unix, linux} ->
+ ok;
+ Platform ->
+ lists:flatten(
+ io_lib:format("Word on platform ~w size"
+ " ~w not supported", [Other,
+ Platform]))
+ end
end
end.
@@ -75,3 +71,46 @@ check_row_count(Expected, Count) ->
to_upper(List) ->
lists:map(fun(Str) -> string:to_upper(Str) end, List).
+
+strict(Ref, mysql) ->
+ odbc:sql_query(Ref, "SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES';");
+strict(_,_) ->
+ ok.
+
+platform_options() ->
+ [].
+
+skip() ->
+ case os:type() of
+ {unix, linux} ->
+ Issue = linux_issue(),
+ is_sles9(Issue);
+ {unix, sunos} ->
+ not supported_solaris();
+ _ ->
+ false
+ end.
+
+supported_solaris() ->
+ case os:version() of
+ {_,10,_} ->
+ true;
+ _ ->
+ false
+ end.
+
+linux_issue() ->
+ {ok, Binary} = file:read_file("/etc/issue"),
+ string:tokens(binary_to_list(Binary), " ").
+
+is_sles11(IssueTokens) ->
+ lists:member("11", IssueTokens).
+
+is_sles10(IssueTokens) ->
+ lists:member("10", IssueTokens).
+
+is_sles9(IssueTokens) ->
+ lists:member("9", IssueTokens).
+
+is_ubuntu(IssueTokens) ->
+ lists:member("Ubuntu", IssueTokens).
diff --git a/lib/odbc/test/oracle.erl b/lib/odbc/test/oracle.erl
index ebf6dbb6bf..d74863d8c1 100644
--- a/lib/odbc/test/oracle.erl
+++ b/lib/odbc/test/oracle.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -108,10 +108,6 @@ create_text_table() ->
" (FIELD long)". %Oracle long is variable length char data
%-------------------------------------------------------------------------
-create_unicode_table() ->
- " (FIELD nvarchar(50))".
-
-%-------------------------------------------------------------------------
create_timestamp_table() ->
" (FIELD DATETIME)".
@@ -231,8 +227,8 @@ param_select() ->
%-------------------------------------------------------------------------
describe_integer() ->
- {ok,[{"INT1",{sql_decimal,38,0}},{"INT2",{sql_decimal,38,0}},
- {"INT3",{sql_decimal,38,0}}]}.
+ {ok,[{"MYINT1",{sql_decimal,38,0}},{"MYINT2",{sql_decimal,38,0}},
+ {"MYINT3",{sql_decimal,38,0}}]}.
describe_string() ->
{ok,[{"STR1",{sql_char,10}},
@@ -243,4 +239,4 @@ describe_string() ->
describe_floating() ->
{ok,[{"F",sql_double},{"R",sql_double},{"D",sql_double}]}.
describe_dec_num() ->
- {ok,[{"DEC",{sql_decimal,9,3}},{"NUM",{sql_decimal,9,2}}]}.
+ {ok,[{"MYDEC",{sql_decimal,9,3}},{"MYNUM",{sql_decimal,9,2}}]}.
diff --git a/lib/odbc/test/postgres.erl b/lib/odbc/test/postgres.erl
index 169ca26e43..d564dbd5ff 100644
--- a/lib/odbc/test/postgres.erl
+++ b/lib/odbc/test/postgres.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -30,7 +30,7 @@ connection_string() ->
{unix, sunos} ->
"DSN=Postgres;UID=odbctest";
{unix, linux} ->
- Size = erlang:system_info(wordsize),
+ Size = erlang:system_info({wordsize, external}),
linux_dist_connection_string(Size)
end.
@@ -43,7 +43,12 @@ linux_dist_connection_string(4) ->
end;
linux_dist_connection_string(_) ->
- "DSN=PostgresLinux64;UID=odbctest".
+ case linux_dist() of
+ "ubuntu" ->
+ "DSN=PostgresLinux64Ubuntu;UID=odbctest";
+ _ ->
+ "DSN=PostgresLinux64;UID=odbctest"
+ end.
linux_dist() ->
case file:read_file("/etc/issue") of
@@ -135,10 +140,6 @@ create_text_table() ->
" (FIELD text)".
%-------------------------------------------------------------------------
-create_unicode_table() ->
- " (FIELD text)".
-
-%-------------------------------------------------------------------------
create_timestamp_table() ->
" (FIELD TIMESTAMP)".
@@ -275,9 +276,9 @@ param_select() ->
%-------------------------------------------------------------------------
describe_integer() ->
- {ok,[{"int1",sql_smallint},
- {"int2",sql_integer},
- {"int3",sql_integer}]}.
+ {ok,[{"myint1",sql_smallint},
+ {"myint2",sql_integer},
+ {"myint3",sql_integer}]}.
describe_string() ->
{ok,[{"str1",{sql_char,10}},
@@ -288,7 +289,7 @@ describe_string() ->
describe_floating() ->
{ok,[{"f",sql_real},{"r",sql_real},{"d",{sql_float,15}}]}.
describe_dec_num() ->
- {ok,[{"dec",{sql_numeric,9,3}},{"num",{sql_numeric,9,2}}]}.
+ {ok,[{"mydec",{sql_numeric,9,3}},{"mynum",{sql_numeric,9,2}}]}.
describe_timestamp() ->
{ok, [{"field", sql_timestamp}]}.
diff --git a/lib/odbc/test/sqlserver.erl b/lib/odbc/test/sqlserver.erl
index e3fe30e0bc..59252d4276 100644
--- a/lib/odbc/test/sqlserver.erl
+++ b/lib/odbc/test/sqlserver.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2002-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2002-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -123,10 +123,6 @@ create_text_table() ->
" (FIELD text)".
%-------------------------------------------------------------------------
-create_unicode_table() ->
- " (FIELD nvarchar(50))".
-
-%-------------------------------------------------------------------------
create_timestamp_table() ->
" (FIELD DATETIME)".
@@ -279,8 +275,8 @@ param_select() ->
%-------------------------------------------------------------------------
describe_integer() ->
- {ok,[{"int1", sql_smallint},{"int2", sql_integer},
- {"int3", sql_integer}]}.
+ {ok,[{"myint1", sql_smallint},{"myint2", sql_integer},
+ {"myint3", sql_integer}]}.
describe_string() ->
{ok,[{"str1",{sql_char,10}},
@@ -292,7 +288,7 @@ describe_floating() ->
{ok,[{"f", sql_real},{"r", sql_real}, {"d", {sql_float, 53}}]}.
describe_dec_num() ->
- {ok,[{"dec",{sql_decimal,9,3}},{"num",{sql_numeric,9,2}}]}.
+ {ok,[{"mydec",{sql_decimal,9,3}},{"mynum",{sql_numeric,9,2}}]}.
describe_timestamp() ->
{ok, [{"field", sql_timestamp}]}.
diff --git a/lib/odbc/vsn.mk b/lib/odbc/vsn.mk
index 42a51be33e..120ed9ee3d 100644
--- a/lib/odbc/vsn.mk
+++ b/lib/odbc/vsn.mk
@@ -1 +1 @@
-ODBC_VSN = 2.10.10
+ODBC_VSN = 2.10.11