Thread: Error: insufficient data in the message
Hi, I around with error with PostgreSQL 9.5.0
Prepared Statment:
INSERT INTO tbCerts (Company_UID, User_UID, Cert_Blob_Size, Cert_Format, After_Date, Before_Date,
Cert_Blob, Password1, Key_Name, Cert_Blob_Type, Cert_Use, Status)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
Binds values:
param[0]=1242004 /* htonl */
param[1]=1242028 /* htonl */
param[2]=135967325878940612 /* htonl */
param[3]=1242076 /* htonl */
param[4]='26/05/2015'
param[5]='25/05/2016'
param[6]=blob size=9529 /* blob with may can 0x0 data, obviously. */
param[7]=3B0429150961134E
param[8]=C:\documentos\RC SOFTWARE\clientes\asbosch\bef.pfx
param[9]=pfx
param[10]=S
param[11]=A
Error: insufficient data in the message
pgsql_pexec error: PQresultStatus=7
Log:
2016-03-16 17:35:07 BRT ERRO: dados insuficientes na mensagem
2016-03-16 17:35:07 BRT COMANDO: INSERT INTO tbCerts (Company_UID, User_UID, Cert_Blob_Size, Cert_Format, After_Date, Before_Date, Cert_Blob, Password1, Key_Name, Cert_Blob_Type, Cert_Use, Status) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
PostgreSQL 9.5.0 32bits
Client 32 bits (libpq.dll)
This is very frustrating, whats is wrog?
How can debug this?
Best,
Ranier Vilela
On 03/16/2016 01:49 PM, Ranier VF wrote: > Hi, I around with error with PostgreSQL 9.5.0 > > Prepared Statment: > INSERT INTO tbCerts (Company_UID, User_UID, Cert_Blob_Size, Cert_Format, > After_Date, Before_Date, > Cert_Blob, Password1, Key_Name, Cert_Blob_Type, Cert_Use, Status) > VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); > > Binds values: > param[0]=1242004 /* htonl */ > param[1]=1242028 /* htonl */ > param[2]=135967325878940612 /* htonl */ > param[3]=1242076 /* htonl */ > param[4]='26/05/2015' > param[5]='25/05/2016' > param[6]=blob size=9529 /* blob with may can 0x0 data, obviously. */ > param[7]=3B0429150961134E > param[8]=C:\documentos\RC SOFTWARE\clientes\asbosch\bef.pfx > param[9]=pfx > param[10]=S > param[11]=A > > Error: insufficient data in the message > pgsql_pexec error: PQresultStatus=7 > > Log: > 2016-03-16 17:35:07 BRT ERRO: dados insuficientes na mensagem > 2016-03-16 17:35:07 BRT COMANDO: INSERT INTO tbCerts (Company_UID, > User_UID, Cert_Blob_Size, Cert_Format, After_Date, Before_Date, > Cert_Blob, Password1, Key_Name, Cert_Blob_Type, Cert_Use, Status) VALUES > ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); > > PostgreSQL 9.5.0 32bits > Client 32 bits (libpq.dll) > > This is very frustrating, whats is wrog? What client are you using to run the query? Are you sure you do not have a one-off error. Your bind values are 0 indexed, while your parameters are not. Could it be they are not matching up? Hard to tell without seeing the complete code. > How can debug this? > > Best, > > Ranier Vilela > -- Adrian Klaver adrian.klaver@aklaver.com
Ranier VF <ranier_gyn@hotmail.com> writes: > Hi, I around with error with PostgreSQL 9.5.0 > Error: insufficient data in the messagepgsql_pexec error: PQresultStatus=7 Hmm ... I can't find the string "insufficient data in the message" anywhere in the Postgres sources. And not "pgsql_pexec" either. So this must be coming from some client-side code you're using (not libpq). It's unlikely we can help you much here; you need to chat with the author of the client-side library that's emitting that error. regards, tom lane
On Fri, Mar 18, 2016 at 9:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Ranier VF <ranier_gyn@hotmail.com> writes: >> Hi, I around with error with PostgreSQL 9.5.0 >> Error: insufficient data in the messagepgsql_pexec error: PQresultStatus=7 > > Hmm ... I can't find the string "insufficient data in the message" > anywhere in the Postgres sources. And not "pgsql_pexec" either. > So this must be coming from some client-side code you're using (not > libpq). It's unlikely we can help you much here; you need to chat with > the author of the client-side library that's emitting that error. > 2016-03-16 17:35:07 BRT ERRO: dados insuficientes na mensagem This is an error message in Portuguese, and it refers to an existing message: #: libpq/pqformat.c:556 libpq/pqformat.c:574 libpq/pqformat.c:595 #: utils/adt/arrayfuncs.c:1444 utils/adt/rowtypes.c:556 #, c-format msgid "insufficient data left in message" msgstr "dados insuficientes na mensagem" Perhaps the driver you are using is indeed linked with libpq and the message translated in Portuguese got translated again? Anyway, we are going to need more details regarding the way you ran this query, and what is the version of libpq used on client-side, which may not be from 9.5.0. Compatibility is ensured with the protocol 3, so that should work anyway. -- Michael
Michael Paquier <michael.paquier@gmail.com> writes: > On Fri, Mar 18, 2016 at 9:00 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Hmm ... I can't find the string "insufficient data in the message" >> anywhere in the Postgres sources. And not "pgsql_pexec" either. >> 2016-03-16 17:35:07 BRT ERRO: dados insuficientes na mensagem > This is an error message in Portuguese, and it refers to an existing message: > #: libpq/pqformat.c:556 libpq/pqformat.c:574 libpq/pqformat.c:595 > #: utils/adt/arrayfuncs.c:1444 utils/adt/rowtypes.c:556 > #, c-format > msgid "insufficient data left in message" Hm. If that's the correct identification, all those message sites are complaining that the client sent invalidly-formatted data. So it still looks like a client-side issue. regards, tom lane
On 03/18/2016 08:49 AM, Ranier VF wrote: Ccing list for real this time, for reasons stated below. > Hi, > > > Per previous posts, the error is not coming from Postgres, but from your > > client software. Some searching indicates pgsql_pexec is part of the > > Asterisk PBX software. Is that the case? > Not. The client code is own. > Yes the error is coming from client code, not from Postgres. > > Libpq.dll (Postgresql 9.5.0), 32 bits, expect BIGINT param. > Own client code can not format correct bits. > > Would be possible, example code in C, to format BIGINT > param with msvc 32 bits compiler? I am not a C programmer and I do almost 0 development on Windows, so I have no answers for the above. Including the list as I am pretty sure there are folks on it who have the answer. > > Best regards, > > Ranier Vilela > > > Subject: Re: [GENERAL] Error: insufficient data in the message > > To: ranier_gyn@hotmail.com > > From: adrian.klaver@aklaver.com > > Date: Fri, 18 Mar 2016 07:50:14 -0700 > > > > On 03/18/2016 07:29 AM, Ranier VF wrote: > > > > Ccing list > > > Hi, Thank your for response. > > > > > > After hard time, find this bug. > > > I see that the problem is. > > > > > > length datatypes, in param[2] > > > field is BIGINT (postgresql) > > > param (num_long var) is unsigned long long (32bits) > > > > > > params[i].data.num_ulong = htonl(params[i].data.num_ulong); > > > prep->bindValues[i] = (const uchar *) > > > ¶ms[i].data.num_ulong; > > > prep->bindLengths[i] = sizeof(ulong); > > > prep->bindFormats[i] = 1; > > > > > > This fail miserably with windows 32bits (xp, Win7). > > > > > > If change to: > > > prep->bindLengths[i] = 8; > > > > > > Postgresql error goes, but the wrong value is inserted. > > > > Per previous posts, the error is not coming from Postgres, but from your > > client software. Some searching indicates pgsql_pexec is part of the > > Asterisk PBX software. Is that the case? > > > > > > > > For while, BIGINT is avoided for us. > > > > > > Best regards, > > > > > > Ranier Vilela > > > > > > -- > > Adrian Klaver > > adrian.klaver@aklaver.com -- Adrian Klaver adrian.klaver@aklaver.com
Replying to Adrian because I'm not seeing some of Ranier's posts. >On 03/18/2016 08:49 AM, Ranier VF wrote: > >> Would be possible, example code in C, to format BIGINT >> param with msvc 32 bits compiler? >> > Subject: Re: [GENERAL] Error: insufficient data in the message >> > To: ranier_gyn@hotmail.com >> > From: adrian.klaver@aklaver.com >> > Date: Fri, 18 Mar 2016 07:50:14 -0700 >> > >> > On 03/18/2016 07:29 AM, Ranier VF wrote: >> > >> > Ccing list >> > > Hi, Thank your for response. >> > > >> > > After hard time, find this bug. >> > > I see that the problem is. >> > > >> > > length datatypes, in param[2] >> > > field is BIGINT (postgresql) >> > > param (num_long var) is unsigned long long (32bits) In 32-bit versions of MSVC, "long long" is 64-bits. Also __int64 (with 2 underscores). >> > > params[i].data.num_ulong = htonl(params[i].data.num_ulong); htonl and ntohl do not work on 64-bit values ... you're changing only the low part. And I'm suprised that you didn't get a compiler warning about this. Windows 8 and higher offer 64-bit versions of these functions: htonll and ntohll (spelled with an extra L), but these functions are not available in XP or Win7. There are portable versions available online or you can easily write them. Depending on your platform they both should either reverse the byte order, or do nothing: TCP's "network" order is big-endian. The compilers in Visual Studio 2003 and up have the function _byteswap_uint64 which will do an 8 byte reversal. >> > > prep->bindValues[i] = (const uchar *) >> > > ¶ms[i].data.num_ulong; >> > > prep->bindLengths[i] = sizeof(ulong); Should be sizeof(ulonglong). >> > > prep->bindFormats[i] = 1; >> > > >> > > This fail miserably with windows 32bits (xp, Win7). >> > > >> > > If change to: >> > > prep->bindLengths[i] = 8; >> > > >> > > Postgresql error goes, but the wrong value is inserted. Yes. The length needs to be 8 for a "long long" value, and the value itself needs to be converted correctly for TCP network byte order. I don't work directly with libpg, so I can't say if anything else is wrong here. Hope this helps, George