pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stefan Olsson <stefan.olsson@noname4us.com>
To: pgsql-interfaces@postgresql.org
Subject: Segmentation fault
Date: Fri, 17 Jul 1998 18:15:55 +0200
Message-ID: <35AF78BB.E0301AA3@noname4us.com> (raw)

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);
}





view thread (10+ messages)  latest in thread

Message-ID: <35AF78BB.E0301AA3@noname4us.com>
Permalink:  ../35AF78BB.E0301AA3@noname4us.com/
Also on:    postgresql.org/message-id/35AF78BB.E0301AA3@noname4us.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: stefan.olsson@noname4us.com
  Subject: Re: Segmentation fault
  In-Reply-To: <35AF78BB.E0301AA3@noname4us.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox