Skip to content

Commit

Permalink
new database driver for Oracle and new timestamp format 'Oracle'
Browse files Browse the repository at this point in the history
  • Loading branch information
willamowius committed Oct 7, 2023
1 parent 083b0ce commit 6705f0d
Show file tree
Hide file tree
Showing 6 changed files with 737 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Toolkit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4042,8 +4042,10 @@ PString Toolkit::AsString(
return tm.AsString(PTime::LongISO8601);
else if (fmtStr *= "RFC822")
return tm.AsString(PTime::RFC1123);
else if (fmtStr *= "MySQL" )
else if (fmtStr *= "MySQL")
fmtStr = "%Y-%m-%d %H:%M:%S";
else if (fmtStr *= "Oracle")
fmtStr = "%d-%b-%Y %I:%M:%S %P";

struct tm _tm;
struct tm* tmptr = &_tm;
Expand Down
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Changes from 5.11 to 5.12
=========================
- new database driver for Oracle and new timestamp format 'Oracle'
- new switch [EP::xxx] ForceDirectMode=1 to handle all calls from this endpoint in direct mode
- BUGFIX(RasSrv.cxx, gkauth.cxx) make sure time_t is handled unsigned to avoid Y2K38 issue
- BUGFIX(ProxyChannel.cxx) check for too small packets when acting as encryption proxy
Expand Down
185 changes: 184 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ with_sqlite_dir
enable_redis
with_redis_include_dir
with_redis_dir
enable_oracle
with_oracle_include_dir
with_oracle_dir
enable_libssh
with_libssh_include_dir
with_libssh_lib_dir
Expand Down Expand Up @@ -1408,6 +1411,7 @@ Optional Features:
--enable-unixodbc enable unixODBC support (default=yes)
--enable-sqlite enable SQLite support (default=yes)
--enable-redis enable redis support (default=yes)
--enable-oracle enable oracle support (default=yes)
--enable-libssh enable libssh support (default=yes)
--enable-netsnmp enable Net-SNMP support (default=yes)
--enable-ptlibsnmp enable PTLib SNMP support (default=yes)
Expand All @@ -1434,6 +1438,8 @@ Optional Packages:
--with-sqlite-dir=DIR base directory where SQLite is installed
--with-redis-include-dir=DIR directory where redis includes may be found
--with-redis-dir=DIR base directory where redis is installed
--with-oracle-include-dir=DIR directory where oracle includes may be found
--with-oracle-dir=DIR base directory where oracle is installed
--with-libssh-include-dir=DIR directory where libssh includes may be found
--with-libssh-lib-dir=DIR directory where libssh libraries may be found
--with-libssh-dir=DIR base directory where libssh is installed
Expand Down Expand Up @@ -5022,7 +5028,184 @@ fi



if test "x$pgsql" != "xno" -o "x$mysql" != "xno" -o "x$firebird" != "xno" -o "x$unixodbc" != "xno" -o "x$sqlite" != "xno" -o "x$redis" != "xno"; then


# Check whether --enable-oracle was given.
if test "${enable_oracle+set}" = set; then :
enableval=$enable_oracle; oracle="${enableval}"
else
oracle="yes"

fi



# Check whether --with-oracle-include-dir was given.
if test "${with_oracle_include_dir+set}" = set; then :
withval=$with_oracle_include_dir; oracle_include_dir="$withval"

fi



# Check whether --with-oracle-dir was given.
if test "${with_oracle_dir+set}" = set; then :
withval=$with_oracle_dir; oracle_include_dir="$withval/include"


fi


if test "x${oracle}" != "xno"; then

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Oracle ODPI-C header (dpi.h)" >&5
$as_echo_n "checking for Oracle ODPI-C header (dpi.h)... " >&6; }

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <dpi.h>
int
main ()
{
int a = 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ORACLE_INCLUDE=" "
else
ORACLE_INCLUDE=

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

if test "x$ORACLE_INCLUDE" = "x"; then
old_CFLAGS="$CFLAGS"

for try in /usr/local/include/ $oracle_include_dir; do
if test -d $try; then
CFLAGS="$old_CFLAGS -I$try"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <dpi.h>
int
main ()
{
int a = 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ORACLE_INCLUDE="-I$try"
else
ORACLE_INCLUDE=

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "x$ORACLE_INCLUDE" != "x"; then
break;
fi
fi
done
CFLAGS="$old_CFLAGS"
fi

if test "x$ORACLE_INCLUDE" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Oracle ODPI headers not found. Use --with-oracle-include-dir=<path>" >&5
$as_echo "$as_me: WARNING: Oracle ODPI headers not found. Use --with-oracle-include-dir=<path>" >&2;}
oracle="no"
else
sql_oracle_cflags="${sql_oracle_cflags} ${ORACLE_INCLUDE}"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Oracle ODPI-C library" >&5
$as_echo_n "checking for Oracle ODPI-C library... " >&6; }

old_CFLAGS="$CFLAGS"
old_LIBS="$LIBS"

for try in /usr/lib /usr/local/lib $oracle_lib_dir; do
if test -d $try; then
CFLAGS="$old_CFLAGS $ORACLE_INCLUDE"
LIBS="$old_LIBS -lodpic"
LDFLAGS="$old_LDFLAGS -L$try"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stddef.h>
#include <dpi.h>
int
main ()
{
dpiContext *gContext; dpiErrorInfo errorInfo; dpiContext_createWithParams(DPI_MAJOR_VERSION, DPI_MINOR_VERSION, NULL, &gContext, &errorInfo);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ORACLE_LIBS="-lodpic"
ORACLE_LDFLAGS="-L$try"

else
ORACLE_LDFLAGS=

fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
if test "x$ORACLE_LDFLAGS" != "x"; then
break;
fi
fi
done
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"

if test "x$ORACLE_LDFLAGS" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
ORACLE_INCLUDE=
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ODPI-C lib not found. Use --with-oracle-lib-dir=<path>" >&5
$as_echo "$as_me: WARNING: ODPI-C lib not found. Use --with-oracle-lib-dir=<path>" >&2;}
oracle="no"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
oracle_ldflags="$oracle_ldflags $ORACLE_LDFLAGS"
fi
fi

oracle_ldflags="$oracle_ldflags $LIBS"


if test "x$oracle" = "xno"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Oracle disabled" >&5
$as_echo "$as_me: WARNING: Oracle disabled" >&2;}
fi
else
oracle="no"
fi

if test "x$oracle" != "xno"; then
HAS_ORACLE=1
$as_echo "#define HAS_ORACLE 1" >>confdefs.h

SOURCES="$SOURCES gksql_oracle.cxx"
STDCCFLAGS="${sql_oracle_cflags} -DHAS_ORACLE=1 $STDCCFLAGS"
LDFLAGS="$ORACLE_LDFLAGS $LDFLAGS"
ENDLDLIBS="$ORACLE_LIBS $ENDLDLIBS"
echo "Oracle support enabled"
else
echo "Oracle support disabled"
HAS_ORACLE=0
fi



if test "x$pgsql" != "xno" -o "x$mysql" != "xno" -o "x$firebird" != "xno" -o "x$unixodbc" != "xno" -o "x$sqlite" != "xno" -o "x$redis" != "xno" -o "x$oracle" != "xno"; then
SOURCES="$SOURCES sqlauth.cxx sqlacct.cxx gksql.cxx"
HEADERS="$HEADERS sqlacct.h gksql.h"
fi
Expand Down
124 changes: 123 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -894,11 +894,133 @@ else
fi
AC_SUBST(HAS_REDIS)

dnl #########################################################################
dnl Check for Oracle and ODPI-C
dnl ########################################################################

dnl MSWIN_DISPLAY oracle,oracle
dnl MSWIN_CHECK_FILE oracle,dpi.h,HAS_ORACLE=1
dnl MSWIN_DIR_SYMBOL oracle,ORACLE_DIR
dnl MSWIN_CHECK_DIR oracle,\odpi\


AC_ARG_ENABLE(oracle,
[ --enable-oracle enable oracle support (default=yes)],
[ oracle="${enableval}" ], [ oracle="yes" ]
)

AC_ARG_WITH(oracle-include-dir,
[ --with-oracle-include-dir=DIR directory where oracle includes may be found ],
[ oracle_include_dir="$withval" ]
)

AC_ARG_WITH(oracle-dir,
[ --with-oracle-dir=DIR base directory where oracle is installed ],
[ oracle_include_dir="$withval/include"
]
)

if test "x${oracle}" != "xno"; then

AC_MSG_CHECKING([for Oracle ODPI-C header (dpi.h)])

AC_TRY_COMPILE([#include <dpi.h>], [int a = 1;],
ORACLE_INCLUDE=" ",
ORACLE_INCLUDE=
)

if test "x$ORACLE_INCLUDE" = "x"; then
old_CFLAGS="$CFLAGS"

for try in /usr/local/include/ $oracle_include_dir; do
if test -d $try; then
CFLAGS="$old_CFLAGS -I$try"
AC_TRY_COMPILE([#include <dpi.h>], [int a = 1;],
ORACLE_INCLUDE="-I$try",
ORACLE_INCLUDE=
)
if test "x$ORACLE_INCLUDE" != "x"; then
break;
fi
fi
done
CFLAGS="$old_CFLAGS"
fi

if test "x$ORACLE_INCLUDE" = "x"; then
AC_MSG_RESULT(no)
AC_MSG_WARN([Oracle ODPI headers not found. Use --with-oracle-include-dir=<path>])
oracle="no"
else
sql_oracle_cflags="${sql_oracle_cflags} ${ORACLE_INCLUDE}"
AC_MSG_RESULT(yes)

AC_MSG_CHECKING([for Oracle ODPI-C library])

old_CFLAGS="$CFLAGS"
old_LIBS="$LIBS"

for try in /usr/lib /usr/local/lib $oracle_lib_dir; do
if test -d $try; then
CFLAGS="$old_CFLAGS $ORACLE_INCLUDE"
LIBS="$old_LIBS -lodpic"
LDFLAGS="$old_LDFLAGS -L$try"
AC_TRY_LINK([#include <stddef.h>
#include <dpi.h>],
[dpiContext *gContext; dpiErrorInfo errorInfo; dpiContext_createWithParams(DPI_MAJOR_VERSION, DPI_MINOR_VERSION, NULL, &gContext, &errorInfo);],
[ ORACLE_LIBS="-lodpic"
ORACLE_LDFLAGS="-L$try"
],
ORACLE_LDFLAGS=
)
if test "x$ORACLE_LDFLAGS" != "x"; then
break;
fi
fi
done
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"

if test "x$ORACLE_LDFLAGS" = "x"; then
AC_MSG_RESULT(no)
ORACLE_INCLUDE=
AC_MSG_WARN([ODPI-C lib not found. Use --with-oracle-lib-dir=<path>])
oracle="no"
else
AC_MSG_RESULT(yes)
oracle_ldflags="$oracle_ldflags $ORACLE_LDFLAGS"
fi
fi

oracle_ldflags="$oracle_ldflags $LIBS"


if test "x$oracle" = "xno"; then
AC_MSG_WARN([Oracle disabled])
fi
else
oracle="no"
fi

if test "x$oracle" != "xno"; then
HAS_ORACLE=1
AC_DEFINE(HAS_ORACLE, 1)
SOURCES="$SOURCES gksql_oracle.cxx"
STDCCFLAGS="${sql_oracle_cflags} -DHAS_ORACLE=1 $STDCCFLAGS"
LDFLAGS="$ORACLE_LDFLAGS $LDFLAGS"
ENDLDLIBS="$ORACLE_LIBS $ENDLDLIBS"
echo "Oracle support enabled"
else
echo "Oracle support disabled"
HAS_ORACLE=0
fi
AC_SUBST(HAS_REDIS)

dnl ########################################################################
dnl enable sqlauth, sqlacc if any DB present
dnl ########################################################################

if test "x$pgsql" != "xno" -o "x$mysql" != "xno" -o "x$firebird" != "xno" -o "x$unixodbc" != "xno" -o "x$sqlite" != "xno" -o "x$redis" != "xno"; then
if test "x$pgsql" != "xno" -o "x$mysql" != "xno" -o "x$firebird" != "xno" -o "x$unixodbc" != "xno" -o "x$sqlite" != "xno" -o "x$redis" != "xno" -o "x$oracle" != "xno"; then
SOURCES="$SOURCES sqlauth.cxx sqlacct.cxx gksql.cxx"
HEADERS="$HEADERS sqlacct.h gksql.h"
fi
Expand Down
5 changes: 3 additions & 2 deletions docs/manual/mainconfig.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ You have to repeat all settings for each module, even if they are the same.
But you are also free to use differend database drivers and options for each module.

<itemize>
<item><tt/Driver=MySQL | PostgreSQL | Firebird | ODBC | SQLite | redis/<newline>
<item><tt/Driver=MySQL | PostgreSQL | Oracle | Firebird | ODBC | SQLite | redis/<newline>
Default: <tt>N/A</tt><newline>
<p>
Database driver to use. Currently, <tt/MySQL/, <tt/PostgreSQL/, <tt/Firebird/,
Database driver to use. Currently, <tt/MySQL/, <tt/PostgreSQL/, <tt/Oracle/, <tt/Firebird/,
<tt/ODBC/, <tt/SQLite/ and <tt/redis/ drivers are implemented.
The MySQL driver can also be used for MariaDB and other MySQL forks.
Not all of these driver are always available. When GnuGk is compiled, only those
Expand Down Expand Up @@ -435,6 +435,7 @@ There are four predefined formats:
<item><tt/ISO8601/ - standard ISO format (example: 2004-11-10 T 16:02:01 +0100)
<item><tt/Cisco/ - format used by Cisco equipment (example: 16:02:01.534 CET Wed Nov 10 2004)
<item><tt/MySQL/ - simple format that MySQL can understand (example: 2004-11-10 16:02:01)
<item><tt/Oracle/ - format suitable for Oracle TIMESTAMP fields (example: 10-Nov-2004 16:02:01 pm)
</itemize>
<p>
If none of the predefined options is suitable, you can build your own format string using
Expand Down
Loading

0 comments on commit 6705f0d

Please sign in to comment.