example program bug?

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема example program bug?
Дата
Msg-id 20010813134915M.t-ishii@sra.co.jp
обсуждение исходный текст
Ответы Re: example program bug?  (Gavin Sherry <swm@linuxworld.com.au>)
Список pgsql-hackers
Included is a example program appears in our docs (libpq.sgml). 
As you can see, the very last part of the program:
   PQfinish(conn);
   return 0;

never execute. Should we remove them?
--
Tatsuo Ishii


main()
{   char       *pghost,              *pgport,              *pgoptions,              *pgtty;   char       *dbName;   int
       nFields;   int         i,               j;
 
   PGconn     *conn;   PGresult   *res;   PGnotify   *notify;
   /*    * begin, by setting the parameters for a backend connection if the    * parameters are null, then the system
willtry to use reasonable    * defaults by looking up environment variables or, failing that,    * using hardwired
constants   */   pghost = NULL;              /* host name of the backend server */   pgport = NULL;              /*
portof the backend server */   pgoptions = NULL;           /* special options to start up the backend
            * server */   pgtty = NULL;               /* debugging tty for the backend server */   dbName =
getenv("USER");   /* change this to the name of your test                                * database */
 
   /* make a connection to the database */   conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
   /*    * check to see that the backend connection was successfully made    */   if (PQstatus(conn) == CONNECTION_BAD)
 {       fprintf(stderr, "Connection to database '%s' failed.\n", dbName);       fprintf(stderr, "%s",
PQerrorMessage(conn));      exit_nicely(conn);   }
 
   res = PQexec(conn, "LISTEN TBL2");   if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)   {       fprintf(stderr,
"LISTENcommand failed\n");       PQclear(res);       exit_nicely(conn);   }
 
   /*    * should PQclear PGresult whenever it is no longer needed to avoid    * memory leaks    */   PQclear(res);
   while (1)   {
       /*        * wait a little bit between checks; waiting with select()        * would be more efficient.        */
    sleep(1);       /* collect any asynchronous backend messages */       PQconsumeInput(conn);       /* check for
asynchronousnotify messages */       while ((notify = PQnotifies(conn)) != NULL)       {           fprintf(stderr,
         "ASYNC NOTIFY of '%s' from backend pid '%d' received\n",                   notify->relname,
notify->be_pid);          free(notify);       }   }
 
   /* close the connection to the database and cleanup */   PQfinish(conn);
   return 0;
}


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Larry Rosenman
Дата:
Сообщение: Makefile.PL for Pg.so
Следующее
От: Ian Lance Taylor
Дата:
Сообщение: Re: Re: [PATCHES] Select parser at runtime