Server side prepared statements 'bit' parameters generate errors.

Поиск
Список
Период
Сортировка
От Johan Levin
Тема Server side prepared statements 'bit' parameters generate errors.
Дата
Msg-id CAGWp_GhfHhNkgjWK6f4XWxF7EyA-c259x2NCxCOTUXB972oFpw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Server side prepared statements 'bit' parameters generate errors.  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-odbc
Hello

I have run into a problem after upgrading from 9.03 to the 9.05.04 ODBC driver. Parameters of type 'bit' seem to be interpreted as 'char' in some cases when using server side prepared statements.

If I execute the query
    select * from some_table where ?;
with a bit parameter then I get an error that reads:
    ERROR [42804] ERROR: argument of WHERE must be type boolean, not type "char";

The error is not reproducible is I set the connection string parameter UseServerSidePrepare=0. It also isn't reproducible in version 9.03 regardless of the value of UseServerSidePrepare. The problem seems to only affect bit parameters. A program that duplicates the problem follows at the end of this email. I am using the driver distributed in "psqlodbc_09_05_0400-x64.zip" on Windows 10. I have tested PostgreSQL version 9.4 and 9.5.

Have I run into a bug in the driver, or is this a server issue? Any help would be much appreciated.

Regards,
Johan Levin




Program listing: (C#)

using System.Data.Odbc;
using System.Diagnostics;
internal class Program
{
    private static void Main(string[] args)
    {
        // Command line: Server, User, Password, Database, UseServerSidePrepare
        // Database schema and data:
        //   create table some_table (id int, name varchar(20));
        //   insert into some_table values (42, 'Arthur Dent');

        Trace.Assert(args.Length == 5, "Wrong number of command line arguments.");
        var connStr = string.Format("Driver={{PostgreSQL Unicode(x64)}};Server={0};Uid={1};Pwd={2};Database={3};UseServerSidePrepare={4}", args);
        using (var connection = new OdbcConnection(connStr))
        using (var command = connection.CreateCommand())
        {
            connection.Open();
            command.CommandText = "select * from some_table where ?;";
            command.Parameters.Add(new OdbcParameter
            {
                OdbcType = OdbcType.Bit,
                Value = 1
            });
            command.ExecuteNonQuery();    // <-- Exception here if UseServerSidePrepare=1
            // OdbcException.Message =
            //   ERROR [42804] ERROR: argument of WHERE must be type boolean, not type "char";
            //   Error while executing the query
        }
    }
}

В списке pgsql-odbc по дате отправления:

Предыдущее
От: Hong06
Дата:
Сообщение: Re: ODBC isolationi level SQL_TXN_SERIALIZABLE -> "08001 Already connected."
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Server side prepared statements 'bit' parameters generate errors.