pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Error in calling a function with protocol 7.4
3+ messages / 2 participants
[nested] [flat]

* Error in calling a function with protocol 7.4
@ 2015-12-09 00:40 Haribabu Kommi <kommi.haribabu@gmail.com>
  2015-12-21 14:41 ` Re: Error in calling a function with protocol 7.4 Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 3+ messages in thread

From: Haribabu Kommi @ 2015-12-09 00:40 UTC (permalink / raw)
  To: pgsql-odbc

when function is called using the following way, it generates an error.

? = CALL procname ()

The error message with 09.03.0400 with protocol 7.4 is
-----------------------------------------------------
errstate -> 08P01
errcode -> 7
errmsg -> ERROR: invalid message format; Error while executing the query
-----------------------------------------------------

But it passes with protocol 6.4 in version 09.03.0400. The same test passes
with either protocol versions in version 09.03.0100.

Function:

CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
AS $$
  BEGIN
    RETURN 1234;
  END;
$$ LANGUAGE 'plpgsql';

Here I attached the sample test file to reproduce the problem. I want to know
whether is it a problem or normal behavior in this version?

Regards,
Hari Babu
Fujitsu Australia

-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc

Attachments:

test.c (text/x-csrc, 1.8K) download #include <stdio.h> #include <stdlib.h> #include <sql.h> #include <sqlext.h> #include <string.h> int main() { HENV henv; HDBC hdbc; char errstate[256] = "99999"; char errmsg[256]; SDWORD errcode; SWORD sz; HSTMT hstmt; int prm_int[1]={100}; char *call = "{?=CALL PROC1()}"; SQLAllocEnv(&henv); SQLAllocConnect(henv, &hdbc); RETCODE retcode = SQLConnect(hdbc, "PostgreSQL", SQL_NTS, "postgres", SQL_NTS, "postgres", SQL_NTS); if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) { printf("Error : SQLConnect\n"); exit(1); } if (SQLAllocStmt(hdbc, &hstmt) != SQL_SUCCESS) { printf("Error : SQLAllocStmt\n"); exit(1); } RETCODE RtCode = SQLBindParameter( (SQLHSTMT) hstmt, (SQLSMALLINT) 1, (SQLSMALLINT) SQL_PARAM_OUTPUT, (SQLSMALLINT) SQL_C_LONG, (SQLSMALLINT) SQL_INTEGER, (SQLINTEGER) 0, (SQLSMALLINT) 0, (PTR) &prm_int, (SQLINTEGER) 0, (SQLLEN *) NULL); if (RtCode != SQL_SUCCESS) { printf("Error : SQLBindParameter\n"); exit(1); } printf("init : %d\n", prm_int[0]); if (SQLExecDirect(hstmt, (UCHAR FAR *)call, SQL_NTS) != SQL_SUCCESS) { SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, 1, errstate, &errcode, errmsg, sizeof(errmsg), &sz); printf("Error : SQLExecDirect\n"); printf("%s(%d) %*s\n", errstate, errcode, (int)sz, errmsg); exit(1); } printf("after: %d\n", prm_int[0]); SQLFreeStmt(hstmt, SQL_RESET_PARAMS); SQLFreeStmt(hstmt, SQL_DROP); SQLTransact(henv, hdbc, SQL_ROLLBACK); SQLDisconnect(hdbc); SQLFreeConnect(hdbc); SQLFreeEnv(henv); return 0; }
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Error in calling a function with protocol 7.4
  2015-12-09 00:40 Error in calling a function with protocol 7.4 Haribabu Kommi <kommi.haribabu@gmail.com>
@ 2015-12-21 14:41 ` Heikki Linnakangas <hlinnaka@iki.fi>
  2015-12-24 04:37   ` Re: Error in calling a function with protocol 7.4 Haribabu Kommi <kommi.haribabu@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Heikki Linnakangas @ 2015-12-21 14:41 UTC (permalink / raw)
  To: Haribabu Kommi <kommi.haribabu@gmail.com>; pgsql-odbc

On 09/12/15 02:40, Haribabu Kommi wrote:
> when function is called using the following way, it generates an error.
>
> ? = CALL procname ()
>
> The error message with 09.03.0400 with protocol 7.4 is
> -----------------------------------------------------
> errstate -> 08P01
> errcode -> 7
> errmsg -> ERROR: invalid message format; Error while executing the query
> -----------------------------------------------------
>
> But it passes with protocol 6.4 in version 09.03.0400. The same test passes
> with either protocol versions in version 09.03.0100.
>
> Function:
>
> CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
> AS $$
>    BEGIN
>      RETURN 1234;
>    END;
> $$ LANGUAGE 'plpgsql';
>
> Here I attached the sample test file to reproduce the problem. I want to know
> whether is it a problem or normal behavior in this version?

It's a bug. I bisected it into commit e6d7ded, which was a bit 
surprising because that commit didn't change the way the parameters are 
handled, AFAICS. In any case, in 'master', the bug was quite clearly in 
libpq_bind_and_exec(): with a not-already-prepared statement, it sent 
the original number of parameters to the server, rather than the number 
of parameters minus the OUT params.

Pushed a fix for this to master. Thanks for the test case!

- Heikki



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Error in calling a function with protocol 7.4
  2015-12-09 00:40 Error in calling a function with protocol 7.4 Haribabu Kommi <kommi.haribabu@gmail.com>
  2015-12-21 14:41 ` Re: Error in calling a function with protocol 7.4 Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-12-24 04:37   ` Haribabu Kommi <kommi.haribabu@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Haribabu Kommi @ 2015-12-24 04:37 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-odbc

On Tue, Dec 22, 2015 at 1:41 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> On 09/12/15 02:40, Haribabu Kommi wrote:
>>
>> when function is called using the following way, it generates an error.
>>
>> ? = CALL procname ()
>>
>> The error message with 09.03.0400 with protocol 7.4 is
>> -----------------------------------------------------
>> errstate -> 08P01
>> errcode -> 7
>> errmsg -> ERROR: invalid message format; Error while executing the query
>> -----------------------------------------------------
>>
>> But it passes with protocol 6.4 in version 09.03.0400. The same test
>> passes
>> with either protocol versions in version 09.03.0100.
>>
>> Function:
>>
>> CREATE OR REPLACE FUNCTION PROC1() RETURNS INTEGER
>> AS $$
>>    BEGIN
>>      RETURN 1234;
>>    END;
>> $$ LANGUAGE 'plpgsql';
>>
>> Here I attached the sample test file to reproduce the problem. I want to
>> know
>> whether is it a problem or normal behavior in this version?
>
>
> It's a bug. I bisected it into commit e6d7ded, which was a bit surprising
> because that commit didn't change the way the parameters are handled,
> AFAICS. In any case, in 'master', the bug was quite clearly in
> libpq_bind_and_exec(): with a not-already-prepared statement, it sent the
> original number of parameters to the server, rather than the number of
> parameters minus the OUT params.
>
> Pushed a fix for this to master. Thanks for the test case!

Thanks for the fix.

Regards,
Hari Babu
Fujitsu Australia


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-12-24 04:37 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09 00:40 Error in calling a function with protocol 7.4 Haribabu Kommi <kommi.haribabu@gmail.com>
2015-12-21 14:41 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-12-24 04:37   ` Haribabu Kommi <kommi.haribabu@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox