Segmentation fault

From: Stefan Olsson <stefan(dot)olsson(at)noname4us(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Segmentation fault
Date: 1998-07-17 16:15:55
Message-ID: 35AF78BB.E0301AA3@noname4us.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi, i am testing PostgreSQL and have already run into questions...

Can someone explain why i don´t get a error message the second time i
run this program saying "TABLE slask ALREADY EXISTS", instead i get
"Segmentation fault (core dumped)"

Thanks !

/Stefan

#include <stdio.h>
#include "libpq-fe.h"

void exit_nicely(PGconn* conn)
{
PQfinish(conn);
exit(1);
}

main()
{
char *pghost, *pgport, *pgoptions, *pgtty;
char* dbName;

PGconn* conn;
PGresult* res;

pghost = NULL;
pgport = NULL;
pgoptions = NULL;
pgtty = NULL;
dbName = "test";

conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);

if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr,"%s",PQerrorMessage(conn));
exit_nicely(conn);
}

// create the table
res = PQexec(conn, "CREATE TABLE slask(name char(20), phone
char(10))");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr,"CREATE TABLE slask failed !");
PQclear(res);
exit_nicely(conn);
}
PQclear(res);

PQfinish(conn);
}

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michael H. Warfield 1998-07-17 16:49:40 Re: [INTERFACES] ODBC driver for Applixware and Unix
Previous Message David Hartwig 1998-07-17 15:18:56 Re: [INTERFACES] perl interface