How do I sort blog entries by categories?
crash in LIBPQ_execute_query
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > PostgreSQL database development > crash in LIBPQ_execute_query­ 2 September 2005 18:29:17

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

crash in LIBPQ_execute_query

Scot Loach 2 September 2005 16:12:01
 Some of the queries we use can be very large.
My code is crashing here:

QResultClass *
LIBPQ_execute_query­(ConnectionClass *self,char *query) {
QResultClass *qres; PGresult *pgres;
char *ptr;
char cmdbuffer[ERROR_MSG_LENGTH + 1];
char errbuffer[ERROR_MSG_LENGTH + 1]; int pos=0;

strcpy(cmdbuffer,qu­ery);


ERROR_MSG_LENGTH is 4096, my query is larger than that.
What's the rationale here and how do we fix it? This works fine with the old driver.

-------------------­--------(end of broadcast)---------­------------------
TIP 5: don't forget to increase your free space map settings

Add comment
Merlin Moncure 2 September 2005 16:45:36 permanent link ]
 
Some of the queries we use can be very large.> My code is crashing here:>
QResultClass *> LIBPQ_execute_query­(ConnectionClass *self,char *query)> {> QResultClass *qres;> PGresult *pgres;> char *ptr;> char cmdbuffer[ERROR_MSG_LENGTH + 1];> char errbuffer[ERROR_MSG_LENGTH + 1];> int pos=0;>
strcpy(cmdbuffer,qu­ery);>
ERROR_MSG_LENGTH is 4096, my query is larger than that.> What's the rationale here and how do we fix it? This works fine with
old driver.

That code is fishy. I should be making strncpy, not strcpy, and I don't
understand why ERROR_MSG_LENGTH is used for the length. The query is
copied again (with strdup) inside QR_set_command.

IMO, it doesn't seem worthwhile to make the extra copy just to be able
to trim spaces leter.

Merlin

-------------------­--------(end of broadcast)---------­------------------
TIP 2: Don't 'kill -9' the postmaster

Add comment
Dave Page 2 September 2005 16:57:30 permanent link ]
 

-----Original Message-----> From: pgsql-odbc-owner@po­stgresql.org > [mailto:p­gsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach> Sent: 02 September 2005 13:12> To: pgsql-odbc@postgres­ql.org> Subject: [ODBC] crash in LIBPQ_execute_query­>
Some of the queries we use can be very large.> My code is crashing here:>
QResultClass *> LIBPQ_execute_query­(ConnectionClass *self,char *query) > { > QResultClass *qres; > PGresult *pgres;> char *ptr;> char cmdbuffer[ERROR_MSG_LENGTH + 1];> char errbuffer[ERROR_MSG_LENGTH + 1]; > int pos=0;>
strcpy(cmdbuffer,qu­ery);>
ERROR_MSG_LENGTH is 4096, my query is larger than that.> What's the rationale here and how do we fix it? This works > fine with the old driver.

Urgh. To be honest, I can't see any need to copy that string at all in
there, so the limit is entirely unwarranted. In addition, there's code
in there marked #ifndef USE_LIBPQ (in LIBPQ_Execute!!), and, it sets the
rowcount to -1 if it can't find a space in the SQL query!

I've tidied that up - patch attached. Please let me know how it goes.

Regards, Dave



-------------------­--------(end of broadcast)---------­------------------
TIP 5: don't forget to increase your free space map settings
Add comment
Scot Loach 2 September 2005 18:21:44 permanent link ]
 That seems to work.
Thanks for the quick reply Dave.

-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: Friday, September 02, 2005 8:58 AM
To: Scot Loach; pgsql-odbc@postgres­ql.org
Cc: Anoop Kumar
Subject: RE: [ODBC] crash in LIBPQ_execute_query­



-----Original Message-----> From: pgsql-odbc-owner@po­stgresql.org > [mailto:p­gsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach> Sent: 02 September 2005 13:12> To: pgsql-odbc@postgres­ql.org> Subject: [ODBC] crash in LIBPQ_execute_query­>
Some of the queries we use can be very large.> My code is crashing here:>
QResultClass *> LIBPQ_execute_query­(ConnectionClass *self,char *query) > { > QResultClass *qres; > PGresult *pgres;> char *ptr;> char cmdbuffer[ERROR_MSG_LENGTH + 1];> char errbuffer[ERROR_MSG_LENGTH + 1]; > int pos=0;>
strcpy(cmdbuffer,qu­ery);>
ERROR_MSG_LENGTH is 4096, my query is larger than that.> What's the rationale here and how do we fix it? This works > fine with the old driver.

Urgh. To be honest, I can't see any need to copy that string at all in
there, so the limit is entirely unwarranted. In addition, there's code
in there marked #ifndef USE_LIBPQ (in LIBPQ_Execute!!), and, it sets the
rowcount to -1 if it can't find a space in the SQL query!

I've tidied that up - patch attached. Please let me know how it goes.

Regards, Dave

-------------------­--------(end of broadcast)---------­------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresq­l.org so that your
message can get through to the mailing list cleanly

Add comment
Dave Page 2 September 2005 18:29:17 permanent link ]
 No probs. I'll apply it to CVS. Thanks for testing.

/D
-----Original Message-----> From: Scot Loach [mailto:sloach@sandvine.com] > Sent: 02 September 2005 15:22> To: Dave Page; pgsql-odbc@postgres­ql.org> Cc: Anoop Kumar> Subject: RE: [ODBC] crash in LIBPQ_execute_query­>
That seems to work.> Thanks for the quick reply Dave.>
-----Original Message-----> From: Dave Page [mailto:dpage@vale-housing.co.uk]> Sent: Friday, September 02, 2005 8:58 AM> To: Scot Loach; pgsql-odbc@postgres­ql.org> Cc: Anoop Kumar> Subject: RE: [ODBC] crash in LIBPQ_execute_query­>
-----Original Message-----> > From: pgsql-odbc-owner@po­stgresql.org > > [mailto:p­gsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach> > Sent: 02 September 2005 13:12> > To: pgsql-odbc@postgres­ql.org> > Subject: [ODBC] crash in LIBPQ_execute_query­> >
Some of the queries we use can be very large.> > My code is crashing here:> >
QResultClass *> > LIBPQ_execute_query­(ConnectionClass *self,char *query) > > { > > QResultClass *qres; > > PGresult *pgres;> > char *ptr;> > char cmdbuffer[ERROR_MSG_LENGTH + 1];> > char errbuffer[ERROR_MSG_LENGTH + 1]; > > int pos=0;> >
strcpy(cmdbuffer,qu­ery);> >
ERROR_MSG_LENGTH is 4096, my query is larger than that.> > What's the rationale here and how do we fix it? This works > > fine with the old driver.>
Urgh. To be honest, I can't see any need to copy that string at all in> there, so the limit is entirely unwarranted. In addition, there's code> in there marked #ifndef USE_LIBPQ (in LIBPQ_Execute!!), and, > it sets the> rowcount to -1 if it can't find a space in the SQL query!>
I've tidied that up - patch attached. Please let me know how it goes.>
Regards, Dave>

-------------------­--------(end of broadcast)---------­------------------
TIP 2: Don't 'kill -9' the postmaster

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > PostgreSQL database development > crash in LIBPQ_execute_query­ 2 September 2005 18:29:17

see also:
to_char bug?
MessageBox in an Event Handler
deploying ie-based windows forms apps
pass tests:
see also:
How to Backup iPod Files to PC or Mac
How to convert M2TS, MTS video to AVI…
How to Copy/Backup DVD(for Mac and…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .