New SOCI Project Leader needed

Maciej Sobczak, current leader of SOCI project has just announced on soci-users mailing list that he is looking for a volunteer willing to take over the project leadership. For someone, who would like to take over the project management responsibilities and has a good understanding of the subject as well as a solid vision of what to do with the project in the future.

SOCI is a database access library for C++ that makes the illusion of embedding SQL queries in the regular C++ code, staying entirely within the Standard C++.

Microsoft Announces SQL Server ODBC Driver for Linux!

Thanks to my, hopefully, open minded attitude, I sometimes let myself to dive into unknown with honest hope to find unexpected.

Today at lunchtime I let myself loose across Twitter archives and I came across an interesting account, or I rather should say: I fell into evil ways. It is @OpenAtMicrosoft. Hmm, another marketing specialist at Microsoft buzz’ing about the NKTOB ™, means new keyword on the block. Or, it is just Microsoft twitting daily menu from their newly opened cafeteria. But now, they presumably say what they mean:

source for info on Microsoft and interoperability, open source and open standards

By the way, it is a foothold of Interoperability @ Microsoft. (For those who may have problems with interpreting the @ sign, like my grandfather for example, it means the same as English word “at” as in Kids at the House.)

In spite of that my eyes nearly dried out of the openness, I went for it and skimmed and voil?: Microsoft Announces SQL Server ODBC Driver for Linux!. It will soon be widely available to customers. Yay!

Yes, you read that right

It’s an evil good news of the day and I’m keen in trying it out as soon as I polish the ODBC backend in SOCI. I hope to stop worrying about which one to use, unixODBC or iODBC, for SQL Server at least. Life may become easier for OGR SQL Server driver users too.

I also hope, Microsoft will consider to offer the fastest development environment for C/C++ programmers for Linux. Namely, Visual Studio.

Yes, I am radically open minded. I can take on the most incredible of challenges, even surfing an inflatable crocodile.

Update on SqlGeometry and POINT EMPTY in WKB

Long time ago I discussed about how SqlGeometry handles POINT EMPTY in WKB format. The SqlGeometry states the definition of OGC GEOMETRY type for Microsoft SQL Server. Shortly, the message was that SqlGeometry implicitly casts POINT EMPTY to MULTIPOINT EMPTY geometry when generating WKB output. PostGIS casts as well, but does it in a consistent way, in my opinion, outputting GEOMETRYCOLLECTION.

Following those findings, I assumed it is not quite correct, or I didn’t like the inconsistency, and I had reported it to Microsoft Connect as a bug: SqlGeometry reports invalid type of WKB of POINT EMPTY.

Recently, I have received a couple of comments from Microsoft to my report. The comments are attached to the report linked above, but I paste them below for completeness and archive:

Our development team for the spatial data types tells me that it is not possible to use a single value for the WKB format of any spatial data type. For the POINT EMPTY, the WKB format does not allow empty points, so we are outputting a MULTIPOINT with zero elements.
In a MULTIPOINT EMPTY, we are stripping out empty points.

The reasoning is technically correct. It’s just Microsoft does it differently. However, as second comment suggests, the current behaviour may change in future:

But we might consider changing it to get consistent behavior.

SOCI 3.1.0 Released

It has been a very long journey since version 3.0.0 of SOCI was released. Namely, it’s been nearly three years. The RERO philosophy didn’t quite kick in somehow, but the new SOCI 3.1.0 is finally out.

The latest package can be downloaded from here http://sourceforge.net/projects/soci/ and the complete documentation is part of the package as well as available on-line at http://soci.sourceforge.net/doc/index.html. The project web page reflects the latest changes as well http://soci.sourceforge.net/.

This new release brings all the developments that took place during the last two years and that were up to now somewhat inconveniently available only from our Git repository. At the same time it also defines the snapshot and a basis for subsequent library evolution.

Here extract from the CHANGES file

Version 3.1.0 differs from 3.0.0 in the following ways:

  • Added Ada language binding
  • Migrated build system from GNU Autotools and Visual Studio projects to CMake
  • CMake build tested with Visual Studio, GCC and clang
  • Incorporated a compromise for naming versioned shared libraries
  • Enhanced and improved integration with Boost libraries: Boost.DateTime, Boost.Fusion, Boost.Optional, Boost.Tuple
  • Bug fixes and improvements in core and backends:
    • Added soci::values::get_properties accessor useful for composing soci::type_conversion
    • Export advanced API of backend loader from DLL
    • Added static factory registration functions for backends
    • Added get_affected_rows operation
    • Fixed thread-safety of connection pool under Windows
    • Fixed bug with dropping const qualifiers when binding to std::vector<soci::indicator>
    • Fixed bug in default initialization of an object of const backend_factory which requires user-provided default constructor (see C++03/C++0x)
    • Fixes for 64-bit builds
    • Removed redundant exchange_traits breaking ODR on LP64
    • Better ODBC support
    • Type conversion support for unsigned integer types
    • Bug ID:1971436 – incorrect rowset copy operations
    • Bug ID:2010367 – memory leak (ODBC)
    • Bug ID:2010409 – invalid memory allocation in define by position (ODBC)
    • Bug ID:2021243 – long long type support in Visual C++
    • Patch ID:2483066 – 64bit Linux and 64bit integer submitted
    • Patch ID:2809809 – Fix build with GCC 4.4
    • Patch ID:2809810 – Fix SQLite3 build with GCC 4.3
    • Patch ID:2581206 – Windows Unicode application
    • Patch ID:3058275 – install target for CMake build submitted
    • Patch ID:3069375 – use $(prefix)/lib64 on AMD64 platforms
    • Improved performance while accessing query results (MySQL)
    • Bug fixes for PROCEDURE support (MySQL)
    • Removed throw statements from mysql_rowid_backend and mysql_blob_backend destructors (MySQL)
    • Verify that prepared statements survive session::reconnect() operation (MySQL)
    • Improved support for time and date (MySQL, PostgreSQL)
    • Fixed bug with strings of length exceeding 255 characters (ODBC)
    • Improved interpretation of the connect string (Oracle)
    • Added handling of unsigned long long (Oracle, SQLite3, PostgreSQL)
    • Fixes in integral types support (PostgreSQL)
    • Support for colon-casts (PostgreSQL)
    • Added possibility for use BLOB (PostgreSQL)
    • Added support for connection property “synchronous=on|off” (SQLite3)
    • Improved BLOB data handling (SQLite3)
    • Improved boolean type support (SQLite3)
    • Session timeout support (SQLite3)
    • Improved tests clean-up (SQLite3)
    • Added missing typedef of sqlite3_destructor_type which has been defined in sqlite3.h but since 3.3.10 (see comment for reference to SQLite ticket)
  • Updated tests for various backends and SQL data types
  • Changed naming conventions and style across all the source code
  • Firebird backend removed from official release as not actively maintained. Available in the Git repository
  • Migrated from CVS to Git repository

On behalf of SOCI Team, I’d like to thank all users and contributors who actively helped us to bring the new release to the public. I have tried hard to list everyone in the AUTHORS file. If anyone has been omitted, it happened by mistake and please don’t hesitate to tell me.

Unfortunately, due to lack of active maintenance the Firebird backend has been removed. Also, the ODBC backend needs more love, especially testing. However, we welcome anyone who is interested in taking over the maintenance of the Firebird backend as well as helping us to test and improve the ODBC backend.

As the author of the CMake configuration, I’m strongly interested in any feedback and constructive critique. Please, feel free to post your comments to soci-users. Do you have any ideas for SOCI backends to other databases? Share it!

We are very excited about this release. It allows us to define the directions for future work. There is plenty of ideas to pursue.

SqlGeometry and POINT EMPTY in WKB

Inspired by question Paul Ramsey asked today morning on IRC, I’ve inspected what kind of Well-Known-Binary output gives SqlGeometry for EMPTY geometries of all the seven geometry types as specified in OGC SFS. The SqlGeometry class is available from SQL Server System CLR Types for .NET Framework. Here we go.

I checked Well-Known-Binary output as returned by the SqlGeometry method STAsBinary(). Here is a small test program written in C#:

using System;
using System.Linq;
using Microsoft.SqlServer.Types;
namespace SqlGeometryEmpty
{
  class Test
  {
    static void Main(string[] args)
    {
      foreach (string type in
         Enum.GetNames(typeof(OpenGisGeometryType)))
      {
        string wkt = type.ToUpper() + " EMPTY";
        SqlGeometry geom = SqlGeometry.Parse(wkt);
        byte[] wkb = geom.STAsBinary().Buffer;
        string wkbhex = string.Join("",
          wkb.Select(
            b => b.ToString("X2")).ToArray());

        Console.WriteLine("{0}\n{1} ({2} bytes)\n",
          wkt, wkbhex, wkb.Length);
      }
    }
  }
}

The first observation is that WKB of EMPTY geometry for all types is returned as a a slightly different binary. All the binary forms are truncated to nine bytes. The first byte indicates endianness as expected. The second chunk of four bytes indicate geometry type. It is exactly as defined in OGC specifications. The third chunk of remaining four bytes are set to Zero and seem to play a role of size specifier: number of points in LINESTRING or number of rings in POLYGON, number of points in MULTIPOINT, and so on. This makes another observation that WKB for EMPTY is reported as a collection of primitive components.

The difference in binary of WKB of EMPTY geometry I mentioned is in that the actual type of input geometry is preserved, so there seems to be no implicit translation to geometry of some other type.

So far so good but not for too long. In fact, SqlGeometry implicitly casts POINT EMPTY to MULTIPOINT EMPTY geometry with the WKB of the following form (in hex):

010400000000000000

Here is complete output of the test program above:

POINT EMPTY
010400000000000000 (9 bytes)

LINESTRING EMPTY
010200000000000000 (9 bytes)

POLYGON EMPTY
010300000000000000 (9 bytes)

MULTIPOINT EMPTY
010400000000000000 (9 bytes)

MULTILINESTRING EMPTY
010500000000000000 (9 bytes)

MULTIPOLYGON EMPTY
010600000000000000 (9 bytes)

GEOMETRYCOLLECTION EMPTY
010700000000000000 (9 bytes)

A word about how PostGIS behaves. PostGIS reports GEOMETRYCOLLECTION EMPTY, regardless of actual type of input EMPTY geometry. It is in hex form:

010700000000000000

Generally, there is not many choices of how to report EMPTY geometry in clear and usable way and a form of collection with size equal to Zero seems to be the most appropriate choice. POINT EMPTY reported with type set to POINT (010100000000000000) would be ambiguous as feels like truncated or invalid form of POINT(0 0), especially in programming languages like C where native dynamic allocated arrays do not carry information about their size. IOW, geometry type is not enough information to process binary form of POINT EMPTY properly.

Reporting EMPTY geometries as a collection is a useful convention that seems to work well. PostGIS behaves about it in the very consistent manner reporting one type for all empties. SqlGeometry, so SQL Server, forces programmers to write a few more lines of code to handle all the possible cases. Yet another original exotic solution from Microsoft.

Consistent API is a bless!

Update: consistent specification of interface is even better.

How PostGIS can help SQL Server users?

I may be a gonzo or it’s just that today I didn’t have my notorious 4th coffee in my favourite Winnie The Pooh cup I got from Pantera on our 14th (or 15th?) anniversary we celebrated a month ago, so…

Apparently, there are situations in which PostGIS could be an affordable anti-GML vaccine jab. It seems there is a potential market for PostGIS to conquer. Perhaps it wouldn’t be estimated as profitable as the H1N1 but who knows what will happen if no one takes a brave stand and stop GML designers! Here I’d eagerly conclude with one of the famous Scottish sentences :-)

Back to the subject matter. Today, I spotted an interesting question on the StackOverflow archives: Is it possible to export spatial data from Sql Server 2008 in gml2 format?. Natively? No, there is no such solution. Presumably, Microsoft thinks forward and thinks GML 2 is a legacy standard. Fair enough, someone has to draw a line between prehistoric and modern, somewhere. Why Microsoft? Again?

Facing such a tremendous suffer Microsoft exposed SQL Server users to, I suggested to visit the “underworld” for a while and hire PostGIS to do the dirty job.

Paraphrasing Andrei Alexan­dres­cu‘s, hysterically famous recently, sentence: SQL Server should go!.