Improve processing of SQLITE_NULL

null-atom can be configured on configure or make stage. For example
./configure --enable-null-atom=undefined && make
This commit is contained in:
sergey-miryanov
2010-07-14 12:47:46 +06:00
parent 7876c0f568
commit b65d2f8bcb
8 changed files with 1775 additions and 2642 deletions

View File

@@ -1,3 +1,3 @@
{'src/sqlite3_lib.erl',[debug_info,{outdir,"ebin"}]}.
{'src/sqlite3_lib.erl',[debug_info,{outdir,"ebin"}, {d, 'NULL_ATOM', 'xxx'}]}.
{'src/sqlite3.erl',[debug_info,{outdir,"ebin"}]}.
{'src/sqlite3_test.erl',[debug_info,{outdir,"ebin"}]}.

3
Emakefile.in Normal file
View File

@@ -0,0 +1,3 @@
{'src/sqlite3_lib.erl',[debug_info,{outdir,"ebin"}, {d, 'NULL_ATOM', '@NULL_ATOM@'}]}.
{'src/sqlite3.erl',[debug_info,{outdir,"ebin"}]}.
{'src/sqlite3_test.erl',[debug_info,{outdir,"ebin"}]}.

View File

@@ -1,4 +1,5 @@
ERL=@ERL@
ERLC=@ERLC@
ERL_KERNEL=@ERLANG_LIB_DIR_kernel@
ERL_STDLIB=@ERLANG_LIB_DIR_stdlib@
ERL_CRYPTO=@ERLANG_LIB_DIR_crypto@

4385
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -41,6 +41,15 @@ AC_ERLANG_CHECK_LIB(compiler)
AC_ERLANG_CHECK_LIB(hipe)
AC_ERLANG_CHECK_LIB(syntax_tools)
AC_ARG_ENABLE([null-atom],
[AC_HELP_STRING([--enable-null-atom=atom],
[Set to configure null-atom, default 'null'])],
[ ac_null_atom=$enableval ],
[ ac_null_atom=null ])
NULL_ATOM="$ac_null_atom"
AC_SUBST([NULL_ATOM])
AC_CONFIG_FILES([Makefile
Emakefile
priv/Makefile])
AC_OUTPUT

View File

@@ -4,7 +4,7 @@ GCC=gcc
LDFLAGS=-shared -L/usr/lib -lsqlite3 -undefined -fPIC -lerl_interface -L$(ERL_INTERFACE)/lib -lei
SRCS=sqlite3_drv.c sqlite3_drv.h
OUTPUT=sqlite3_drv.so
CFLAGS=-o ../ebin/${OUTPUT} -I$(ERL_ROOT)/usr/include/ -I$(ERL_INTERFACE)/include/
CFLAGS=-o ../ebin/${OUTPUT} -I$(ERL_ROOT)/usr/include/ -I$(ERL_INTERFACE)/include/ -DNULL_ATOM=@NULL_ATOM@
all: ../ebin/${OUTPUT}

View File

@@ -65,10 +65,12 @@ static ErlDrvData start(ErlDrvPort port, char* cmd) {
retval->db = db;
retval->key = 42; //FIXME: Just a magic number, make real key
#define STR_(ARG) #ARG
#define STR(ARG) STR_(ARG)
retval->atom_error = driver_mk_atom ("error");
retval->atom_columns = driver_mk_atom ("columns");
retval->atom_rows = driver_mk_atom ("rows");
retval->atom_null = driver_mk_atom ("null");
retval->atom_null = driver_mk_atom (STR (NULL_ATOM));
retval->atom_id = driver_mk_atom ("id");
retval->atom_ok = driver_mk_atom ("ok");
retval->atom_unknown_cmd = driver_mk_atom ("uknown_command");

View File

@@ -50,12 +50,11 @@ col_type("DATE") ->
%%--------------------------------------------------------------------
-spec(write_value_sql/1::(any()) -> string()).
write_value_sql(Values) ->
StrValues = lists:map(fun(X) when is_integer(X) ->
integer_to_list(X);
(X) when is_float(X) ->
float_to_list(X);
(X) ->
io_lib:format("'~s'", [X])
StrValues = lists:map(fun
(X) when is_integer(X) -> integer_to_list(X);
(X) when is_float(X) -> float_to_list(X);
(?NULL_ATOM) -> 'null';
(X) -> io_lib:format("'~s'", [X])
end, Values),
string:join(StrValues, ",").