Skip to content

Commit

Permalink
Solutions for #15, #24, #45, #49
Browse files Browse the repository at this point in the history
- Much improved logging system
- EXEC SQL WHENEVER support
- New formats for "connection strings", including an ocesql-compatible one
- The MySQL driver now links against (and ships with) the MariaDB client libraries
- PostgreSQL client library (libpq) has been updated
- Binary dependencies are now installed with vcpkg (on Windows)
- autoconf can now also build on MinGW
- Fixed memory problems and misc warnings (merged PRs by @GitMensch)
  • Loading branch information
mridoni committed Jun 27, 2022
1 parent 0ec1114 commit fcf53de
Show file tree
Hide file tree
Showing 145 changed files with 95 additions and 26,654 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
=== v1.0.16 ======================================================
- Much improved logging system
- EXEC SQL WHENEVER support
- New formats for "connection strings", including an ocesql-compatible one
- The MySQL driver now links against (and ships with) the MariaDB client libraries
- PostgreSQL client library (libpq) has been updated
- Binary dependencies are now installed with vcpkg (on Windows)
- autoconf can now also build on MinGW
- Fixed memory problems and misc warnings (merged PRs by @GitMensch)

=== v1.0.15 ======================================================
- Fixed "long queries break COBOL compiler" (#8)
- Fixed a couple of possible parser crashes
Expand Down
54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ For cases 2) and 3) the DB/driver type is inferred by:

- setting a compile-time constant (compile-time means "when GixSQL is compiled"):
- manually in default_driver.h (e.g. #define GIXSQL_DEFAULT_DRIVER "pgsql")
- using the --with-default-driver=pgsql|odbc|mysql|none when calling configure (Linux only)
- if this costant is missing or empty (default), the content of the environment variable `GIXSQL_DEFAULT_DRIVER` is used
- using the --with-default-driver=pgsql|odbc|mysql|none when calling configure (Linux/MinGW only)
- if this costant is missing or empty (default), the content of the environment variable `GIXSQL_DEFAULT_DRIVER` is used. If no default driver is available (either set by the user or provided by the compile-time configuration) and none has been specified in the user-supplied connection string, the library will return an error.



Expand Down Expand Up @@ -230,7 +230,15 @@ Notes:

### Logging

In case of errors or to log what is happening you may want to enable logging using the environment variables `GIXSQL_DEBUG_LOG-ON=1` (which defaults to 0=OFF) and `GIXSQL_DEBUG_LOG` (defaults to "gixsql.log" in your temp directory). While the logging mechanism will be extended in the future, for now this only works for debug builds of GixSQL.
Starting from version 1.0.16 GixSQL supports an improved logging engine, based on [spdlog](https://github.com/gabime/spdlog). Logging options can be controlled by using two environment variables:

- **GIXSQL_DEBUG_LOG_LEVEL**
Sets the debug level. It can be `off` (default), `critical`, `error`, `warn`, `info`, `debug` or `trace`. Be aware that the `trace` option: 1) exposes a lot of internal information, including possibly sensitive data. 2) causes a slowdown of about 30%.

- **GIXSQL_DEBUG_LOG_FILE**
Specifies the file where the debug output (if any) is written. Defaults to "gixsql.log"

*Pre -v1.0.16*: you can use the environment variables `GIXSQL_DEBUG_LOG-ON=1` (which defaults to 0=OFF) and `GIXSQL_DEBUG_LOG` (defaults to "gixsql.log" in your temp directory). This mechanism has been removed in v1.0.16+

### Examples

Expand All @@ -243,8 +251,8 @@ If you want to manually precompile COBOL programs for ESQL, you can use the prep

```text
gixpp - the ESQL preprocessor for Gix-IDE/GixSQL
Version: 1.0.15
libgixpp version: 1.0.15
Version: 1.0.16
libgixpp version: 1.0.16
Options:
-h, --help displays help on commandline options
Expand Down Expand Up @@ -368,35 +376,47 @@ Keep pressing 'y' to advance in the loop and display all the three records in th

### Windows (Visual Studio)

For now you will have to clone the whole repository or the source package that includes the IDE. In the top-level directory, beside the main solution file for Gix-IDE (`gix-ide.sln`) you will find a second solution file (`gixsql.sln`). You can use Visual Studio 2019 to build it, but first you likely will have to adjust the include and library definitions for the PostgreSQL and MySQL client libraries (32/and or 64 bit). The preprocessor (`gixpp`) and the main library (`libgixsql`) do not have any specific dependency.
After cloning or downloading the repository you will find a solution file (`gixsql.sln`). You can use Visual Studio 2019 to build it, but first you will likely have to check the include and library definitions for the PostgreSQL and MySQL client libraries (32/and or 64 bit). The preprocessor (`gixpp`) does not have any specific dependency, while the main runtime library (`libgixsql`) - starting from v1.0.18 - depends on [spdlog](https://github.com/gabime/spdlog) and [fmt](https://github.com/fmtlib/fmt).

The solution file is already set up to build with libraries from [vcpkg](https://vcpkg.io/en/index.html), so you can simply do:

`vcpkg install libpq:x64-windows libmariadb:x64-windows fmt:x64-windows-static-md spdlog:x64-windows-static-md`

for x64, or :

`vcpkg install libpq:x86-windows libmariadb:x86-windows fmt:x86-windows-static-md spdlog:x86-windows-static-md`

in case you wanto to build a 32-bit version.

### Linux

*All comands and packages refer to Ubuntu 20.04, You might need to adjust them depending on your distribution or environment.*

You will need the development packages for the DBMS client libraries, e.g.:

apt install libmysqlclient-dev libpq-dev unixodbc-dev flex
apt install libmariadb-dev libpq-dev unixodbc-dev flex

*(it is still possibile to use libmysqlclient-dev, should you prefer it).*

You will also need a modern enough version of bison. If you are using Ubuntu 20.04, you can download it from Debian's repositories and install it over the current one:
You will also need a modern enough version of bison (3.7+). If you do not already have it installed and you are using Ubuntu 20.04, you can download it from Debian's repositories and install it over the current one:

wget http://ftp.debian.org/debian/pool/main/b/bison/bison_3.7.6+dfsg-1_amd64.deb
wget http://ftp.debian.org/debian/pool/main/b/bison/bison_3.7.5+dfsg-1_amd64.deb

and

sudo dpkg -i bison_3.7.6+dfsg-1_amd64.deb
sudo dpkg -i bison_3.7.5+dfsg-1_amd64.deb

Download the .tar.gz.package from the Releases page, e.g.

gixsql-1.0.8-xxxx.tar.gz
gixsql-1.0.16-xxxx.tar.gz

Untar the package:

tar xzvf gixsql-1.0.8-1541.tar.gz
tar xzvf gixsql-1.0.16-641.tar.gz

cd to the directory created by the tar command and run configure (in this case we will install to /opt/gixsql)

cd gixsql-1.0.8-1541
cd gixsql-1.0.16-641
./configure --prefix=/opt/gixsql

By default configure tries to build all the drivers. If you nly need one, you can disable the others. For instance, to build only the PostgreSQL driver:
Expand All @@ -411,9 +431,13 @@ It should compile all the libraries, then the preprocessing library and the prep

sudo make install

### Windows (MinGW)
Currently there are no specific Makefiles/autoconf scripts for MinGW x86/x64, they will be provided in a future release, but you can try to use the configure script.
### Windows (MinGW/MSYS2)

Starting from v1.0.16, the `configure` script can also be used to build with MSYS2 (MinGW32/64). You will need to install the following packages with `pacman`:

`pacman -S mingw-w64-x64-pkg-config autoconf make automake libtool bison flex mingw-w64-x64-gcc mingw-w64-x64-postgresql mingw-w64-x64-libmariadbclient mingw-w64-x64-unixodbc mingw-w64-x64-spdlog `

Reasonably up-to-date installs of MinGW already have a correct version of `bison`.

### Using GixSQL from Gix-IDE
When you create a project in Gix-IDE, you are asked whether you want to enable it for ESQL preprocessing. This is not an absolute requirement. At any point you can set the project property "Preprocess for ESQL" (under "General") to "Yes". There are several properties you can configure here that affed code generation by the preprocessor:
Expand Down
12 changes: 1 addition & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AM_PROG_AR
AC_PROG_YACC
AC_PROG_LEX

LT_INIT(win32-dll)
LT_INIT
AC_SUBST([LIBTOOL_DEPS])

# Checks for header files.
Expand Down Expand Up @@ -63,16 +63,6 @@ case "${host_os}" in
;;
esac

# By default, libtool for mingw refuses to link static libs into a dll for
# fear of mixing pic/non-pic objects, and import/export complications. Since
# we have those under control, re-enable that functionality.
case $host in
*mingw*)
echo "MinGW detected, setting libtool behaviour as 'pass_all'"
export lt_cv_deplibs_check_method='pass_all'
;;
esac

# Pass the conditionals to automake
AM_CONDITIONAL([BUILD_LINUX], [test "$build_linux" = "yes"])
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
Expand Down
2 changes: 1 addition & 1 deletion deploy/installers/windows/gixsql.iss
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Source: "{#REDIST_DIR}\mysql\x86\gcc\*"; DestDir: "{app}\lib\x86\gcc"; Flags: ig
Filename: "{tmp}\redist\ms\x64\VC_redist.x64.exe"; Parameters: "/install /passive /norestart"; WorkingDir: "{tmp}\redist\ms\x64\"; Flags: waituntilterminated; Description: "Visual C++ 2019 redistributable package (x64)"
#endif
Filename: "{tmp}\redist\ms\x86\VC_redist.x86.exe"; Parameters: "/install /passive /norestart"; WorkingDir: "{tmp}\redist\ms\x86\"; Flags: waituntilterminated; Description: "Visual C++ 2019 redistributable package (x86)"
Filename: "{tmp}\redist\ms\x86\vcredist_x86_vs2013.exe"; Parameters: "/install /passive /norestart"; WorkingDir: "{tmp}\redist\ms\x86\"; Flags: waituntilterminated; Description: "Visual C++ 2013 redistributable package (x86)"
; Filename: "{tmp}\redist\ms\x86\vcredist_x86_vs2013.exe"; Parameters: "/install /passive /norestart"; WorkingDir: "{tmp}\redist\ms\x86\"; Flags: waituntilterminated; Description: "Visual C++ 2013 redistributable package (x86)"
#endif

[Registry]
Expand Down
2 changes: 1 addition & 1 deletion gixpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ USA.
#define PATH_LIST_SEP ":"
#endif

#define GIXPP_VER "1.0.16dev2"
#define GIXPP_VER "1.0.16"

using namespace popl;

Expand Down
3 changes: 3 additions & 0 deletions gixsql-tests/GixSqlTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public void Begin()
data_sources.Add(new Tuple<string, int>(ga.type, ga.index));
Assert.IsTrue(data_source_init(data_sources.Count - 1));
}

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_LEVEL", "trace");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_FILE", Path.Combine(TestTempDir, "gisql-" + this.GetType().Name + ".log"));
}

protected DbConnection GetConnection(int ds_index = 0)
Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL001.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL001 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}

[TestMethod]
Expand Down
5 changes: 1 addition & 4 deletions gixsql-tests/TSQL002.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL002 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down Expand Up @@ -45,6 +41,7 @@ public void TSQL002A_MSVC_mysql_x64_exe()
{
compile(CompilerType.MSVC, "release", "x64", "exe");

Environment.SetEnvironmentVariable("DATASRC", build_data_source_string(true, true, true));
Environment.SetEnvironmentVariable("DATASRC", build_data_source_string(true, true, true));
Environment.SetEnvironmentVariable("DATASRC_USR", get_datasource_usr() + "." + get_datasource_pwd());

Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL003.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL003 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
3 changes: 0 additions & 3 deletions gixsql-tests/TSQL004.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public class TSQL004 : GixSqlTestBase
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL005.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL005 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL006.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class TSQL006 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL007.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class TSQL007 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL008.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class TSQL008 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL009.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL009 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
7 changes: 2 additions & 5 deletions gixsql-tests/TSQL010.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ namespace gixsql_tests
{
[TestClass]
[HostPlatform("x64")]
[TestCategory("COBOL TYPEDEF handling")]
//[TestCategory("COBOL TYPEDEF handling")]
[TestCategory("Expected to fail: not implemented")]
public class TSQL010 : GixSqlTestBase
{
[TestInitialize]
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL011.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL011 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL012.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL012 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL013.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL013 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL014.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL014 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL015.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public class TSQL015 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}


Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL016.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL016 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}

[TestMethod]
Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL017.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL017 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}

// This should trap a preprocess error
Expand Down
4 changes: 0 additions & 4 deletions gixsql-tests/TSQL018.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class TSQL018 : GixSqlTestBase
public new void Begin()
{
base.Begin();

Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG_ON", "1");
Environment.SetEnvironmentVariable("GIXSQL_DEBUG_LOG", Path.Combine(TestTempDir, "gisql-debug.log"));
Environment.SetEnvironmentVariable("GIXSQL_ERR_LOG", Path.Combine(TestTempDir, "gisql-error.log"));
}

[TestMethod]
Expand Down
Loading

0 comments on commit fcf53de

Please sign in to comment.