Re: BUG #2606: (libpq) incorrect function declaration - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #2606: (libpq) incorrect function declaration
Date
Msg-id 200609071537.k87FbPN21965@momjian.us
Whole thread Raw
In response to BUG #2606: (libpq) incorrect function declaration in libpq-fe.h  ("Marc ROGLIANO" <marc@rogliano.net>)
List pgsql-bugs
Marc ROGLIANO wrote:
>
> The following bug has been logged online:
>
> Bug reference:      2606
> Logged by:          Marc ROGLIANO
> Email address:      marc@rogliano.net
> PostgreSQL version: 8.1.4
> Operating system:   Windows XP
> Description:        (libpq) incorrect function declaration in libpq-fe.h
> Details:
>
> Hello,
>
> In libpq-fe.h, the function lo_write is declared :
>
> extern int lo_write(PGconn *conn, int fd, char *buf, size_t len);
> => 'const' missing before char *buf : buf should not be writable here

Right, patch attached and applied.  Interestingly, it was documented as
taking a 'const' there, but not implemented as const in the code.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/libpq/be-fsstubs.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v
retrieving revision 1.82
diff -c -c -r1.82 be-fsstubs.c
*** src/backend/libpq/be-fsstubs.c    26 Apr 2006 00:34:57 -0000    1.82
--- src/backend/libpq/be-fsstubs.c    7 Sep 2006 15:34:28 -0000
***************
*** 165,171 ****
  }

  int
! lo_write(int fd, char *buf, int len)
  {
      int            status;

--- 165,171 ----
  }

  int
! lo_write(int fd, const char *buf, int len)
  {
      int            status;

Index: src/backend/storage/large_object/inv_api.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v
retrieving revision 1.119
diff -c -c -r1.119 inv_api.c
*** src/backend/storage/large_object/inv_api.c    31 Jul 2006 20:09:05 -0000    1.119
--- src/backend/storage/large_object/inv_api.c    7 Sep 2006 15:34:29 -0000
***************
*** 488,494 ****
  }

  int
! inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
  {
      int            nwritten = 0;
      int            n;
--- 488,494 ----
  }

  int
! inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
  {
      int            nwritten = 0;
      int            n;
Index: src/include/libpq/be-fsstubs.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/libpq/be-fsstubs.h,v
retrieving revision 1.26
diff -c -c -r1.26 be-fsstubs.h
*** src/include/libpq/be-fsstubs.h    5 Mar 2006 15:58:56 -0000    1.26
--- src/include/libpq/be-fsstubs.h    7 Sep 2006 15:34:30 -0000
***************
*** 41,47 ****
   * but too late now...
   */
  extern int    lo_read(int fd, char *buf, int len);
! extern int    lo_write(int fd, char *buf, int len);

  /*
   * Cleanup LOs at xact commit/abort
--- 41,47 ----
   * but too late now...
   */
  extern int    lo_read(int fd, char *buf, int len);
! extern int    lo_write(int fd, const char *buf, int len);

  /*
   * Cleanup LOs at xact commit/abort
Index: src/include/storage/large_object.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/storage/large_object.h,v
retrieving revision 1.34
diff -c -c -r1.34 large_object.h
*** src/include/storage/large_object.h    26 Apr 2006 00:34:57 -0000    1.34
--- src/include/storage/large_object.h    7 Sep 2006 15:34:30 -0000
***************
*** 77,82 ****
  extern int    inv_seek(LargeObjectDesc *obj_desc, int offset, int whence);
  extern int    inv_tell(LargeObjectDesc *obj_desc);
  extern int    inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
! extern int    inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes);

  #endif   /* LARGE_OBJECT_H */
--- 77,82 ----
  extern int    inv_seek(LargeObjectDesc *obj_desc, int offset, int whence);
  extern int    inv_tell(LargeObjectDesc *obj_desc);
  extern int    inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
! extern int    inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes);

  #endif   /* LARGE_OBJECT_H */
Index: src/interfaces/libpq/fe-lobj.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v
retrieving revision 1.58
diff -c -c -r1.58 fe-lobj.c
*** src/interfaces/libpq/fe-lobj.c    14 Jun 2006 17:49:25 -0000    1.58
--- src/interfaces/libpq/fe-lobj.c    7 Sep 2006 15:34:30 -0000
***************
*** 172,178 ****
   * returns the number of bytes written, or -1 on failure.
   */
  int
! lo_write(PGconn *conn, int fd, char *buf, size_t len)
  {
      PQArgBlock    argv[2];
      PGresult   *res;
--- 172,178 ----
   * returns the number of bytes written, or -1 on failure.
   */
  int
! lo_write(PGconn *conn, int fd, const char *buf, size_t len)
  {
      PQArgBlock    argv[2];
      PGresult   *res;
Index: src/interfaces/libpq/libpq-fe.h
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/libpq-fe.h,v
retrieving revision 1.132
diff -c -c -r1.132 libpq-fe.h
*** src/interfaces/libpq/libpq-fe.h    18 Aug 2006 19:52:39 -0000    1.132
--- src/interfaces/libpq/libpq-fe.h    7 Sep 2006 15:34:30 -0000
***************
*** 483,489 ****
  extern int    lo_open(PGconn *conn, Oid lobjId, int mode);
  extern int    lo_close(PGconn *conn, int fd);
  extern int    lo_read(PGconn *conn, int fd, char *buf, size_t len);
! extern int    lo_write(PGconn *conn, int fd, char *buf, size_t len);
  extern int    lo_lseek(PGconn *conn, int fd, int offset, int whence);
  extern Oid    lo_creat(PGconn *conn, int mode);
  extern Oid    lo_create(PGconn *conn, Oid lobjId);
--- 483,489 ----
  extern int    lo_open(PGconn *conn, Oid lobjId, int mode);
  extern int    lo_close(PGconn *conn, int fd);
  extern int    lo_read(PGconn *conn, int fd, char *buf, size_t len);
! extern int    lo_write(PGconn *conn, int fd, const char *buf, size_t len);
  extern int    lo_lseek(PGconn *conn, int fd, int offset, int whence);
  extern Oid    lo_creat(PGconn *conn, int mode);
  extern Oid    lo_create(PGconn *conn, Oid lobjId);

pgsql-bugs by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: [PATCHES] BUG #2600: dblink compile with SSL missing libraries
Next
From: Shelby Cain
Date:
Subject: Re: BUG #2609: server crash at 182 connections still alive.