2000-01-19 00:30:24 +01:00
|
|
|
/*
|
|
|
|
* psql - the PostgreSQL interactive terminal
|
|
|
|
*
|
2000-01-29 17:58:54 +01:00
|
|
|
* Copyright 2000 by PostgreSQL Global Development Group
|
2000-01-19 00:30:24 +01:00
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.8 2000/04/12 17:16:23 momjian Exp $
|
2000-01-19 00:30:24 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This implements a sort of variable repository. One could also think of it
|
1999-11-04 22:56:02 +01:00
|
|
|
* as cheap version of an associative array. In each one of these
|
|
|
|
* datastructures you can store name/value pairs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VARIABLES_H
|
|
|
|
#define VARIABLES_H
|
|
|
|
|
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
|
|
|
#define VALID_VARIABLE_CHARS "abcdefghijklmnopqrstuvwxyz"\
|
2000-04-12 19:17:23 +02:00
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_"
|
1999-11-04 22:56:02 +01:00
|
|
|
|
1999-11-05 00:14:30 +01:00
|
|
|
struct _variable
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
struct _variable *next;
|
1999-11-04 22:56:02 +01:00
|
|
|
};
|
|
|
|
|
1999-11-05 00:14:30 +01:00
|
|
|
typedef struct _variable *VariableSpace;
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
VariableSpace CreateVariableSpace(void);
|
1999-11-05 00:14:30 +01:00
|
|
|
const char *GetVariable(VariableSpace space, const char *name);
|
|
|
|
bool GetVariableBool(VariableSpace space, const char *name);
|
|
|
|
bool SetVariable(VariableSpace space, const char *name, const char *value);
|
2000-04-12 19:17:23 +02:00
|
|
|
bool SetVariableBool(VariableSpace space, const char *name);
|
1999-11-05 00:14:30 +01:00
|
|
|
bool DeleteVariable(VariableSpace space, const char *name);
|
|
|
|
void DestroyVariableSpace(VariableSpace space);
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
|
1999-11-05 00:14:30 +01:00
|
|
|
#endif /* VARIABLES_H */
|