psql can be induced to dump core, simply by trying to list out all the databases using psql. From a quick perusal of the code, it seemed that the variable pqres was being used without being initialised in some cases. The fix below initialises pqres to a sane value.
Apply this patch.
*** src/bin/psql/psql.c.orig Mon May 01 14:28:01 1995
--- src/bin/psql/psql.c Sat May 06 09:30:32 1995
***************
*** 218,225 ****
int status = 0;
TgDb* db = *db_ptr;
char* dbname = db->name;
- char* host = db->host;
- char* port = db->port;
switch (line[1])
{
--- 218,223 ----
***************
*** 246,255 ****
}
else
{
printf("closing connection to database:%s\n", dbname);
! TgCloseDB(db);
! TG_FREEDB(db);
! db = TgNewDB(newdbname, host, port, NULL, NULL);
*db_ptr = db;
printf("connecting to new database: %s\n", newdbname);
if (TgConnectDB(db) == 0)
--- 244,255 ----
}
else
{
+ TgDb *olddb;
+
printf("closing connection to database:%s\n", dbname);
! olddb = db;
! TgCloseDB(olddb);
! db = TgNewDB(newdbname, olddb->host, olddb->port, NULL, NULL);
*db_ptr = db;
printf("connecting to new database: %s\n", newdbname);
if (TgConnectDB(db) == 0)
***************
*** 256,262 ****
{
fprintf(stderr,"%s\n", tgDbErrMsg);
printf("reconnecting to %s\n", dbname);
! db = TgNewDB(dbname, host, port, NULL, NULL);
*db_ptr = db;
if (TgConnectDB(db) == 0)
{
--- 256,262 ----
{
fprintf(stderr,"%s\n", tgDbErrMsg);
printf("reconnecting to %s\n", dbname);
! db = TgNewDB(dbname, olddb->host, olddb->port, NULL, NULL);
*db_ptr = db;
if (TgConnectDB(db) == 0)
{
***************
*** 266,275 ****
status = 1;
break;
}
! dbname = dupstr(newdbname);
free(*prompt_ptr);
! *prompt_ptr = malloc(strlen(dbname) + 10);
! sprintf(*prompt_ptr,"%s=> ", dbname);
status = 1;
break;
}
--- 266,275 ----
status = 1;
break;
}
! TG_FREEDB(olddb);
free(*prompt_ptr);
! *prompt_ptr = malloc(strlen(newdbname) + 10);
! sprintf(*prompt_ptr,"%s=> ", newdbname);
status = 1;
break;
}
*** src/bin/psql/tdb.c.orig Mon May 01 16:55:56 1995
--- src/bin/psql/tdb.c Wed May 10 16:36:25 1995
***************
*** 281,288 ****
--- 281,290 ----
*/
{
char* pqres;
+ char c = 0;
int ngroups;
+ pqres = &c;
if (db->status == 0) {
sprintf(tgDbErrMsg, "No connection with the database");
return 0;
***************
*** 309,315 ****
{
db->portal = NULL;
}
! }
if (*pqres == 'B') { /* copy to stdout */
handle_copy_out();
--- 311,318 ----
{
db->portal = NULL;
}
! } else
! return 1;
if (*pqres == 'B') { /* copy to stdout */
handle_copy_out();