comparison modules/postgresql/postgresql.c @ 4933:77e3b19bd245

merge
author Ben Wing <ben@xemacs.org>
date Sun, 24 Jan 2010 22:06:20 -0600
parents 8b63e21b0436
children 19a72041c5ed
comparison
equal deleted inserted replaced
4883:f730384b8ddf 4933:77e3b19bd245
118 Lisp_Object Vpg_coding_system; 118 Lisp_Object Vpg_coding_system;
119 #endif 119 #endif
120 120
121 #define CHECK_LIVE_CONNECTION(P) do { \ 121 #define CHECK_LIVE_CONNECTION(P) do { \
122 if (!P || (PQstatus (P) != CONNECTION_OK)) { \ 122 if (!P || (PQstatus (P) != CONNECTION_OK)) { \
123 char *e = "bad value"; \ 123 const char *e = "bad value"; \
124 if (P) e = PQerrorMessage (P); \ 124 if (P) e = PQerrorMessage (P); \
125 signal_ferror (Qprocess_error, "dead connection [%s]", e); \ 125 signal_ferror (Qprocess_error, "dead connection [%s]", e); \
126 } } while (0) 126 } } while (0)
127 #define PUKE_IF_NULL(p) do { \ 127 #define PUKE_IF_NULL(p) do { \
128 if (!p) signal_error (Qinvalid_argument, "bad value", Qunbound); \ 128 if (!p) signal_error (Qinvalid_argument, "bad value", Qunbound); \
201 int UNUSED (escapeflag)) 201 int UNUSED (escapeflag))
202 { 202 {
203 char buf[256]; 203 char buf[256];
204 PGconn *P; 204 PGconn *P;
205 ConnStatusType cst; 205 ConnStatusType cst;
206 char *host="", *db="", *user="", *port=""; 206 const char *host="", *db="", *user="", *port="";
207 207
208 P = (XPGCONN (obj))->pgconn; 208 P = (XPGCONN (obj))->pgconn;
209 209
210 if (!P) /* this may happen since we allow PQfinish() to be called */ 210 if (!P) /* this may happen since we allow PQfinish() to be called */
211 strcpy (buf, "#<PGconn DEAD>"); /* evil! */ 211 strcpy (buf, "#<PGconn DEAD>"); /* evil! */
470 */ 470 */
471 (conninfo)) 471 (conninfo))
472 { 472 {
473 PGconn *P; 473 PGconn *P;
474 Lisp_PGconn *lisp_pgconn; 474 Lisp_PGconn *lisp_pgconn;
475 char *error_message = "Out of Memory?"; 475 const char *error_message = "Out of Memory?";
476 char *c_conninfo; 476 char *c_conninfo;
477 477
478 CHECK_STRING (conninfo); 478 CHECK_STRING (conninfo);
479 479
480 TO_EXTERNAL_FORMAT(LISP_STRING, conninfo, 480 TO_EXTERNAL_FORMAT(LISP_STRING, conninfo,
515 */ 515 */
516 (conninfo)) 516 (conninfo))
517 { 517 {
518 PGconn *P; 518 PGconn *P;
519 Lisp_PGconn *lisp_pgconn; 519 Lisp_PGconn *lisp_pgconn;
520 char *error_message = "Out of Memory?"; 520 const char *error_message = "Out of Memory?";
521 char *c_conninfo; 521 char *c_conninfo;
522 522
523 CHECK_STRING (conninfo); 523 CHECK_STRING (conninfo);
524 TO_EXTERNAL_FORMAT (LISP_STRING, conninfo, 524 TO_EXTERNAL_FORMAT (LISP_STRING, conninfo,
525 C_STRING_ALLOCA, c_conninfo, Qnative); 525 C_STRING_ALLOCA, c_conninfo, Qnative);
917 TO_EXTERNAL_FORMAT (LISP_STRING, query, 917 TO_EXTERNAL_FORMAT (LISP_STRING, query,
918 C_STRING_ALLOCA, c_query, Qnative); 918 C_STRING_ALLOCA, c_query, Qnative);
919 919
920 R = PQexec (P, c_query); 920 R = PQexec (P, c_query);
921 { 921 {
922 char *tag, buf[BLCKSZ]; 922 const Ascbyte *tag;
923 char buf[BLCKSZ];
923 924
924 if (!R) out_of_memory ("query: out of memory", Qunbound); 925 if (!R) out_of_memory ("query: out of memory", Qunbound);
925 else 926 else
926 switch (PQresultStatus (R)) 927 switch (PQresultStatus (R))
927 { 928 {
990 991
991 R = PQgetResult (P); 992 R = PQgetResult (P);
992 if (!R) return Qnil; /* not an error, there's no more data to get */ 993 if (!R) return Qnil; /* not an error, there's no more data to get */
993 994
994 { 995 {
995 char *tag, buf[BLCKSZ]; 996 const Ascbyte *tag;
997 char buf[BLCKSZ];
996 998
997 switch (PQresultStatus (R)) 999 switch (PQresultStatus (R))
998 { 1000 {
999 case PGRES_BAD_RESPONSE: 1001 case PGRES_BAD_RESPONSE:
1000 tag = "bad response [%s]"; 1002 tag = "bad response [%s]";