Commit a576a60e authored by Bruce Momjian's avatar Bruce Momjian

Show backend status on ps command line. Remove unused args from

pg_exec_query().
parent 99d21d5b
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.11 1998/01/05 16:39:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.12 1998/06/04 17:26:38 momjian Exp $
*
* NOTES
* At the point the version is defined, 2 physical relations are created
......@@ -95,7 +95,7 @@ eval_as_new_xact(char *query)
* CommitTransactionCommand(); StartTransactionCommand();
*/
CommandCounterIncrement();
pg_exec_query(query, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(query);
}
#endif
......@@ -157,7 +157,7 @@ VersionCreate(char *vname, char *bname)
sprintf(query_buf, "SELECT * INTO TABLE %s from %s where 1 =2",
vname, bname);
pg_exec_query(query_buf, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(query_buf);
/*
* Creating the ``v_added'' relation
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.13 1998/04/27 04:05:11 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.14 1998/06/04 17:26:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -95,7 +95,7 @@ createdb(char *dbname, char *dbpath)
sprintf(buf, "insert into pg_database (datname, datdba, datpath)"
" values (\'%s\', \'%d\', \'%s\');", dbname, user_id, loc);
pg_exec_query(buf, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(buf);
}
void
......@@ -133,7 +133,7 @@ destroydb(char *dbname)
*/
sprintf(buf, "delete from pg_database where pg_database.oid = \'%d\'::oid",
db_id);
pg_exec_query(buf, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(buf);
/*
* remove the data directory. If the DELETE above failed, this will
......
......@@ -65,7 +65,7 @@ UpdatePgPwdFile(char *sql)
* file to its final name.
*/
sprintf(sql, "copy %s to '%s' using delimiters %s", ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
pg_exec_query(sql, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(sql);
rename(tempname, filename);
free((void *) tempname);
......@@ -196,7 +196,7 @@ DefineUser(CreateUserStmt *stmt)
}
strcat(sql_end, ")");
pg_exec_query(sql, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(sql);
/*
* Add the stuff here for groups.
......@@ -328,7 +328,7 @@ AlterUser(AlterUserStmt *stmt)
{
sql_end += strlen(sql_end);
sprintf(sql_end, " where usename = '%s'", stmt->user);
pg_exec_query(sql, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(sql);
}
/* do the pg_group stuff here */
......@@ -450,7 +450,7 @@ RemoveUser(char *user)
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
sprintf(sql, "drop database %s", dbase[ndbase]);
free((void *) dbase[ndbase]);
pg_exec_query(sql, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(sql);
}
if (dbase)
free((void *) dbase);
......@@ -477,7 +477,7 @@ RemoveUser(char *user)
* Remove the user from the pg_shadow table
*/
sprintf(sql, "delete from %s where usename = '%s'", ShadowRelationName, user);
pg_exec_query(sql, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(sql);
UpdatePgPwdFile(sql);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.15 1998/02/26 04:31:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.16 1998/06/04 17:26:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -147,7 +147,7 @@ PQexec(char *query)
* end up on the top of the portal stack.
* ----------------
*/
pg_exec_query_dest(query, (char **) NULL, (Oid *) NULL, 0, Local);
pg_exec_query_dest(query, Local);
/* ----------------
* pop the portal off the portal stack and return the
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.19 1998/05/12 21:43:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.20 1998/06/04 17:26:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -102,5 +102,5 @@ main(int argc, char *argv[])
exit(BootstrapMain(argc - 1, argv + 1)); /* remove the -boot arg
* from the command line */
else
exit(PostgresMain(argc, argv));
exit(PostgresMain(argc, argv, argc, argv));
}
......@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.79 1998/05/29 17:10:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.80 1998/06/04 17:26:41 momjian Exp $
*
* NOTES
*
......@@ -157,7 +157,8 @@ static IpcMemoryKey ipc_key;
static int NextBackendId = MAXINT; /* XXX why? */
static char *progname = (char *) NULL;
static char **argv_name;
static char **real_argv;
static int real_argc;
/*
* Default Values
......@@ -296,9 +297,37 @@ PostmasterMain(int argc, char *argv[])
int silentflag = 0;
bool DataDirOK; /* We have a usable PGDATA value */
char hostbuf[MAXHOSTNAMELEN];
int nonblank_argc;
/*
* We need three params so we can display status. If we don't
* get them from the user, let's make them ourselves.
*/
if (argc < 4)
{
int i;
char *new_argv[5];
for (i=0; i < argc; i++)
new_argv[i] = argv[i];
for (; i < 4; i++)
new_argv[i] = "";
new_argv[4] = NULL;
execv(new_argv[0], new_argv);
perror("");
/* How did we get here, error! */
fprintf(stderr, "PostmasterMain execv failed on %s\n", argv[0]);
exit(1);
}
progname = argv[0];
argv_name = &argv[0];
real_argv = argv;
real_argc = argc;
/* don't process any dummy args we placed at the end for status display */
for (nonblank_argc = argc; argc > 0; nonblank_argc--)
if (argv[argc-1] != NULL && argv[argc-1][0] != '\0')
break;
/*
* for security, no dir or file created can be group or other
......@@ -316,7 +345,7 @@ PostmasterMain(int argc, char *argv[])
DataDir = getenv("PGDATA"); /* default value */
opterr = 0;
while ((opt = getopt(argc, argv, "a:B:b:D:dim:Mno:p:Ss")) != EOF)
while ((opt = getopt(nonblank_argc, argv, "a:B:b:D:dim:Mno:p:Ss")) != EOF)
{
switch (opt)
{
......@@ -355,7 +384,7 @@ PostmasterMain(int argc, char *argv[])
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
if ((optind < argc) && *argv[optind] != '-')
if ((optind < nonblank_argc) && *argv[optind] != '-')
{
DebugLvl = atoi(argv[optind]);
optind++;
......@@ -1195,7 +1224,7 @@ DoBackend(Port *port)
* a big win.
*/
*argv_name = Execfile;
real_argv[0] = Execfile;
/* Tell the backend it is being called from the postmaster */
av[ac++] = "-p";
......@@ -1252,7 +1281,7 @@ DoBackend(Port *port)
fprintf(stderr, ")\n");
}
return(PostgresMain(ac, av));
return(PostgresMain(ac, av, real_argc, real_argv));
}
/*
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.14 1998/01/13 04:04:12 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.15 1998/06/04 17:26:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -135,7 +135,7 @@ InsertRule(char *rulname,
rulname, evtype, eventrel_oid, evslot_index, actionbuf,
qualbuf, is_instead);
pg_exec_query(rulebuf, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(rulebuf);
return (LastOidProcessed);
}
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.72 1998/05/29 17:00:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.73 1998/06/04 17:26:45 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
......@@ -94,6 +94,7 @@ static bool DebugPrintRewrittenParsetree = false;
/*static bool EnableRewrite = true; , never changes why have it*/
CommandDest whereToSendOutput;
const char **ps_status; /* this is our 'ps' status, argv[3] */
#ifdef LOCK_MGR_DEBUG
extern int lockDebug;
......@@ -594,16 +595,13 @@ pg_parse_and_plan(char *query_string, /* string to execute */
*/
void
pg_exec_query(char *query_string, char **argv, Oid *typev, int nargs)
pg_exec_query(char *query_string)
{
pg_exec_query_dest(query_string, argv, typev, nargs, whereToSendOutput);
pg_exec_query_dest(query_string, whereToSendOutput);
}
void
pg_exec_query_dest(char *query_string, /* string to execute */
char **argv, /* arguments */
Oid *typev, /* argument types */
int nargs, /* number of arguments */
CommandDest dest) /* where results should go */
{
List *plan_list;
......@@ -614,7 +612,7 @@ pg_exec_query_dest(char *query_string, /* string to execute */
QueryTreeList *querytree_list;
/* plan the queries */
plan_list = pg_parse_and_plan(query_string, typev, nargs, &querytree_list, dest);
plan_list = pg_parse_and_plan(query_string, NULL, 0, &querytree_list, dest);
if (QueryCancel)
CancelQuery();
......@@ -697,7 +695,7 @@ pg_exec_query_dest(char *query_string, /* string to execute */
time(&tim);
printf("\tProcessQuery() at %s\n", ctime(&tim));
}
ProcessQuery(querytree, plan, argv, typev, nargs, dest);
ProcessQuery(querytree, plan, dest);
}
if (ShowExecutorStats)
......@@ -827,7 +825,7 @@ usage(char *progname)
* ----------------------------------------------------------------
*/
int
PostgresMain(int argc, char *argv[])
PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
{
bool flagC = false,
flagQ = false,
......@@ -1230,6 +1228,25 @@ PostgresMain(int argc, char *argv[])
puts("\t----------------\n");
}
/* ----------------
* set process params for ps
* ----------------
*/
if (IsUnderPostmaster)
{
int i;
Assert(real_argc >= 4);
real_argv[1] = userName;
real_argv[2] = DBName;
ps_status = (const char **)&real_argv[3];
*ps_status = "idle";
for (i = 4; i < real_argc; i++)
real_argv[i] = ""; /* blank them */
}
/* we just put a dummy here so we don't have to test everywhere */
else ps_status = malloc(sizeof(char *));
/* ----------------
* initialize portal file descriptors
* ----------------
......@@ -1297,7 +1314,7 @@ PostgresMain(int argc, char *argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface");
puts("$Revision: 1.72 $ $Date: 1998/05/29 17:00:15 $");
puts("$Revision: 1.73 $ $Date: 1998/06/04 17:26:45 $");
}
/* ----------------
......@@ -1347,6 +1364,7 @@ PostgresMain(int argc, char *argv[])
StartTransactionCommand();
HandleFunctionRequest();
*ps_status = "idle";
break;
/* ----------------
......@@ -1383,7 +1401,9 @@ PostgresMain(int argc, char *argv[])
}
StartTransactionCommand();
pg_exec_query(parser_input, (char **) NULL, (Oid *) NULL, 0);
pg_exec_query(parser_input);
*ps_status = "idle";
if (ShowStats)
ShowUsage();
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.15 1998/02/26 04:36:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.16 1998/06/04 17:26:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -41,6 +41,8 @@
static char *CreateOperationTag(int operationType);
static void ProcessQueryDesc(QueryDesc *queryDesc);
extern const char **ps_status; /* from postgres.c */
/* ----------------------------------------------------------------
* CreateQueryDesc
......@@ -226,7 +228,7 @@ ProcessQueryDesc(QueryDesc *queryDesc)
plan = queryDesc->plantree;
operation = queryDesc->operation;
tag = CreateOperationTag(operation);
*ps_status = tag = CreateOperationTag(operation);
dest = queryDesc->dest;
/* ----------------
......@@ -358,9 +360,6 @@ ProcessQueryDesc(QueryDesc *queryDesc)
void
ProcessQuery(Query *parsetree,
Plan *plan,
char *argv[],
Oid *typev,
int nargs,
CommandDest dest)
{
QueryDesc *queryDesc;
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pquery.h,v 1.9 1998/02/26 04:43:40 momjian Exp $
* $Id: pquery.h,v 1.10 1998/06/04 17:26:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -29,7 +29,6 @@ ProcessPortal(char *portalName, Query *parseTree,
CommandDest dest);
extern void
ProcessQuery(Query *parsetree, Plan *plan, char *argv[],
Oid *typev, int nargs, CommandDest dest);
ProcessQuery(Query *parsetree, Plan *plan, CommandDest dest);
#endif /* pqueryIncluded */
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tcopprot.h,v 1.13 1998/05/29 17:00:28 momjian Exp $
* $Id: tcopprot.h,v 1.14 1998/06/04 17:26:49 momjian Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
......@@ -25,10 +25,9 @@
extern List *
pg_parse_and_plan(char *query_string, Oid *typev, int nargs,
QueryTreeList **queryListP, CommandDest dest);
extern void pg_exec_query(char *query_string, char **argv, Oid *typev, int nargs);
extern void pg_exec_query(char *query_string);
extern void
pg_exec_query_dest(char *query_string, char **argv, Oid *typev,
int nargs, CommandDest dest);
pg_exec_query_dest(char *query_string, CommandDest dest);
#endif /* BOOTSTRAP_HEADER */
......@@ -37,7 +36,8 @@ extern void quickdie(SIGNAL_ARGS);
extern void die(SIGNAL_ARGS);
extern void FloatExceptionHandler(SIGNAL_ARGS);
extern void CancelQuery(void);
extern int PostgresMain(int argc, char *argv[]);
extern int PostgresMain(int argc, char *argv[],
int real_argc, char *real_argv[]);
extern void ResetUsage(void);
extern void ShowUsage(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment