Skip site navigation (1) Skip section navigation (2)

Patch for NOTICE messages to PQfn() from backend

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Patch for NOTICE messages to PQfn() from backend
Date: 1998-04-28 10:10:00
Message-ID: 199804281110.MAA23122@linda.lfix.co.uk (view raw or flat)
Thread:
Lists: pgsql-hackers
If PQfn() receives NOTICEs from the backend, it fails because there is no
provision to deal with them.

This patch (supplied by Anders Hammarquist <iko(at)netg(dot)se> to me as Debian
maintainer of postgresql) cures the problem:

diff -cr postgresql-6.3.2.orig/src/interfaces/libpq/fe-exec.c 
postgresql-6.3.2/src/interfaces/libpq/fe-exec.c
*** postgresql-6.3.2.orig/src/interfaces/libpq/fe-exec.c	Mon Mar 16 08:0
0:26 
1998
- --- postgresql-6.3.2/src/interfaces/libpq/fe-exec.c	Tue Apr 28 06:47:22 199
8
***************
*** 1545,1556 ****
  	}
  	pqFlush(pfout, pfdebug);
  
! 	id = pqGetc(pfin, pfdebug);
! 	if (id != 'V')
  	{
  		if (id == 'E')
  		{
  			pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfde
bug);
  		}
  		else
  			sprintf(conn->errorMessage,
- --- 1545,1570 ----
  	}
  	pqFlush(pfout, pfdebug);
  
! 	while ((id = pqGetc(pfin, pfdebug)) != 'V')
  	{
  		if (id == 'E')
  		{
  			pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfde
bug);
+ 		}
+ 		else if (id == 'N')
+ 	        {
+ 	               /* print notice and go back to processing return 
+ 			   values */
+ 	               if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, 
+ 				pfin, pfdebug) == 1)
+ 			{
+ 				sprintf(conn->errorMessage,
+ 				"Notice return detected from backend, but "
+ 				"message cannot be read");
+ 			}
+ 			else
+ 				fprintf(stderr, "%s\n", conn->errorMessage);
+ 			continue;
  		}
  		else
  			sprintf(conn->errorMessage,


-- 
Oliver Elphick                                Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight                              http://www.lfix.co.uk/oliver

PGP key from public servers; key ID 32B8FAA1

                 ========================================
    Come to me, all you who labour and are heavily laden, and I will
    give you rest. Take my yoke upon you, and learn from me; for I am
    meek and lowly in heart, and you shall find rest for your souls.
    For my yoke is easy and my burden is light.    (Matthew 11: 28-30)



pgsql-hackers by date

Next:From: Robert HiltibidalDate: 1998-04-28 12:15:53
Subject: Re: [QUESTIONS] Postgres still dying on insert
Previous:From: Oliver ElphickDate: 1998-04-28 10:04:43
Subject: Re: Bug#21681: postgresql: Doesn't allow granting to www-data

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group