Client 4—An Interactive Query Processor

To wrap up this chapter, you'll convert the interactive query processor from the previous chapter into a libpgeasy client.

Most of the code remains the same, so I'll point out only the differences. The most important change is that you no longer have to pass the PGconn * (connection handle) to every function-libpgeasy is managing the connection handle for you.

 1 /* 2 ** File: client4.c 3 */ 4 5 #include <stdlib.h> 6 #include <string.h> 7 #include <libpq-fe.h> 8 #include <libpgeasy.h> 9 #include <readline/readline.h> 10 #include <readline/history.h> 11 12 typedef enum { FALSE, TRUE } bool; 13 14 #define MAX_PRINT_LEN 40 15 16 static char separator[MAX_PRINT_LEN+1]; 17 18 void print_result_set( PGresult ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.