Re: [PATCHES] Add missing const qualifier in ECPG

2005-11-30 Thread Michael Meskes
I just applied most of your patch to 8.0, 8.1 and HEAD. The only thing I
didn't is:

diff -c -r1.7 memory.c
*** ecpglib/memory.c15 Oct 2005 02:49:47 -  1.7
--- ecpglib/memory.c16 Nov 2005 00:40:57 -
***
*** 11,17 
 void
 ECPGfree(void *ptr)
 {
!   free(ptr);
 }

 char *
--- 11,18 
 void
 ECPGfree(void *ptr)
 {
!   if (ptr)
!   free(ptr);
 }

 char *

Is there a reason why you changed this? Acocrding to the docs free(NULL)
does nothing anyway.

Also you mentioned:
...
seems we allow strdup() fails silently in various
places. Shall we do something about it?
...

Yes! Thanks for pointing this out. I already committed a patch that
changes alls strdup() calls to ECPGstrdup() calls that correctly raise
an error condition.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: [EMAIL PROTECTED]
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [PATCHES] Add missing const qualifier in ECPG

2005-11-15 Thread Qingqing Zhou


On Sun, 13 Nov 2005, Peter Eisentraut wrote:
 
  !   (*stmt)-command = (char *)query;
  (*stmt)-connection = connection;
  (*stmt)-lineno = lineno;
  (*stmt)-compat = compat;

 This sort of cheating should be avoided.


According to Peter's comment, revised patch is attached. It duplicates the
values of the query string and free it at the end of the query. There is
another question -- seems we allow strdup() fails silently in various
places. Shall we do something about it?

Regards,
Qingqing

---

Index: ecpglib/descriptor.c
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v
retrieving revision 1.12
diff -c -r1.12 descriptor.c
*** ecpglib/descriptor.c29 Aug 2004 05:06:59 -  1.12
--- ecpglib/descriptor.c16 Nov 2005 00:40:57 -
***
*** 49,55 
  }

  bool
! ECPGget_desc_header(int lineno, char *desc_name, int *count)
  {
PGresult   *ECPGresult;
struct sqlca_t *sqlca = ECPGget_sqlca();
--- 49,55 
  }

  bool
! ECPGget_desc_header(int lineno, const char *desc_name, int *count)
  {
PGresult   *ECPGresult;
struct sqlca_t *sqlca = ECPGget_sqlca();
***
*** 188,194 
  }

  bool
! ECPGget_desc(int lineno, char *desc_name, int index,...)
  {
va_list args;
PGresult   *ECPGresult;
--- 188,194 
  }

  bool
! ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
va_list args;
PGresult   *ECPGresult;
***
*** 431,437 
  }

  bool
! ECPGset_desc_header(int lineno, char *desc_name, int count)
  {
struct descriptor *desc;

--- 431,437 
  }

  bool
! ECPGset_desc_header(int lineno, const char *desc_name, int count)
  {
struct descriptor *desc;

***
*** 452,458 
  }

  bool
! ECPGset_desc(int lineno, char *desc_name, int index,...)
  {
va_list args;
struct descriptor *desc;
--- 452,458 
  }

  bool
! ECPGset_desc(int lineno, const char *desc_name, int index,...)
  {
va_list args;
struct descriptor *desc;
Index: ecpglib/execute.c
===
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v
retrieving revision 1.43
diff -c -r1.43 execute.c
*** ecpglib/execute.c   15 Oct 2005 02:49:47 -  1.43
--- ecpglib/execute.c   16 Nov 2005 00:40:57 -
***
*** 141,147 
   * ind_offset - indicator offset
   */
  static bool
! create_statement(int lineno, int compat, int force_indicator, struct 
connection * connection, struct statement ** stmt, char *query, va_list ap)
  {
struct variable **list = ((*stmt)-inlist);
enum ECPGttype type;
--- 141,148 
   * ind_offset - indicator offset
   */
  static bool
! create_statement(int lineno, int compat, int force_indicator, struct 
connection * connection, struct statement ** stmt, const char
! *query, va_list ap)
  {
struct variable **list = ((*stmt)-inlist);
enum ECPGttype type;
***
*** 149,155 
if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct statement), 
lineno)))
return false;

!   (*stmt)-command = query;
(*stmt)-connection = connection;
(*stmt)-lineno = lineno;
(*stmt)-compat = compat;
--- 150,156 
if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct statement), 
lineno)))
return false;

!   (*stmt)-command = strdup(query);
(*stmt)-connection = connection;
(*stmt)-lineno = lineno;
(*stmt)-compat = compat;
***
*** 224,229 
--- 225,231 
return;
free_variable(stmt-inlist);
free_variable(stmt-outlist);
+   ECPGfree(stmt-command);
ECPGfree(stmt);
  }

***
*** 1359,1365 
  }

  bool
! ECPGdo(int lineno, int compat, int force_indicator, const char 
*connection_name, char *query,...)
  {
va_list args;
struct statement *stmt;
--- 1361,1367 
  }

  bool
! ECPGdo(int lineno, int compat, int force_indicator, const char 
*connection_name, const char *query,...)
  {
va_list args;
struct statement *stmt;
***
*** 1417,1423 
  ECPGdo_descriptor(int line, const char *connection,
  const char *descriptor, const char *query)
  {
!   return ECPGdo(line, ECPG_COMPAT_PGSQL, true, connection, (char *) 
query, ECPGt_EOIT,
  ECPGt_descriptor, descriptor, 0L, 0L, 0L,
  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, 
ECPGt_EORT);
  }
--- 1419,1425 
  ECPGdo_descriptor(int line, const char *connection,
  const char *descriptor, const char *query)
  {
!   return ECPGdo(line, ECPG_COMPAT_PGSQL, true, 

Re: [PATCHES] Add missing const qualifier in ECPG

2005-11-12 Thread Peter Eisentraut
Qingqing Zhou wrote:
 ***
 *** 149,155 
   if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct
 statement), lineno))) return false;

 ! (*stmt)-command = query;
   (*stmt)-connection = connection;
   (*stmt)-lineno = lineno;
   (*stmt)-compat = compat;
 --- 150,156 
   if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct
 statement), lineno))) return false;

 ! (*stmt)-command = (char *)query;
   (*stmt)-connection = connection;
   (*stmt)-lineno = lineno;
   (*stmt)-compat = compat;

This sort of cheating should be avoided.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

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


Re: [PATCHES] Add missing const qualifier in ECPG

2005-11-12 Thread Qingqing Zhou


On Sat, 12 Nov 2005, Peter Eisentraut wrote:

 Qingqing Zhou wrote:
  ***
  *** 149,155 
  if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct
  statement), lineno))) return false;
 
  !   (*stmt)-command = query;
  (*stmt)-connection = connection;
  (*stmt)-lineno = lineno;
  (*stmt)-compat = compat;
  --- 150,156 
  if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct
  statement), lineno))) return false;
 
  !   (*stmt)-command = (char *)query;
  (*stmt)-connection = connection;
  (*stmt)-lineno = lineno;
  (*stmt)-compat = compat;

 This sort of cheating should be avoided.



Yeah ... this is a cheating trade ... :-)

*** 1417,1423 
  ECPGdo_descriptor(int line, const char *connection,
  const char *descriptor, const char *query)
  {
!   return ECPGdo(line, ECPG_COMPAT_PGSQL, true, connection, (char *) 
query, ECPGt_EOIT,
  ECPGt_descriptor, descriptor, 0L, 0L, 0L,
  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, 
ECPGt_EORT);
  }
--- 1418,1424 
  ECPGdo_descriptor(int line, const char *connection,
  const char *descriptor, const char *query)
  {
!   return ECPGdo(line, ECPG_COMPAT_PGSQL, true, connection, query, 
ECPGt_EOIT,
  ECPGt_descriptor, descriptor, 0L, 0L, 0L,
  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, 
ECPGt_EORT);
  }

Regards,
Qingqing

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org