mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
A few minor psql enhancements
Initdb help correction Changed end/abort to commit/rollback and changed related notices Commented out way old printing functions in libpq Fixed a typo in alter table / alter column
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.59 2000/01/26 05:56:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.60 2000/01/29 16:58:29 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@@ -1331,7 +1331,7 @@ BeginTransactionBlock(void)
|
||||
return;
|
||||
|
||||
if (s->blockState != TBLOCK_DEFAULT)
|
||||
elog(NOTICE, "BeginTransactionBlock and not in default state ");
|
||||
elog(NOTICE, "BEGIN: already a transaction in progress");
|
||||
|
||||
/* ----------------
|
||||
* set the current transaction block state information
|
||||
@@ -1404,7 +1404,7 @@ EndTransactionBlock(void)
|
||||
* default state.
|
||||
* ----------------
|
||||
*/
|
||||
elog(NOTICE, "EndTransactionBlock and not inprogress/abort state ");
|
||||
elog(NOTICE, "COMMIT: no transaction in progress");
|
||||
s->blockState = TBLOCK_ENDABORT;
|
||||
}
|
||||
|
||||
@@ -1516,13 +1516,13 @@ UserAbortTransactionBlock()
|
||||
|
||||
/* ----------------
|
||||
* this case should not be possible, because it would mean
|
||||
* the user entered an "abort" from outside a transaction block.
|
||||
* the user entered a "rollback" from outside a transaction block.
|
||||
* So we print an error message, abort the transaction and
|
||||
* enter the "ENDABORT" state so we will end up in the default
|
||||
* state after the upcoming CommitTransactionCommand().
|
||||
* ----------------
|
||||
*/
|
||||
elog(NOTICE, "UserAbortTransactionBlock and not in in-progress state");
|
||||
elog(NOTICE, "ROLLBACK: no transaction in progress");
|
||||
AbortTransaction();
|
||||
s->blockState = TBLOCK_ENDABORT;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.66 2000/01/26 05:56:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.67 2000/01/29 16:58:34 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The PortalExecutorHeapMemory crap needs to be eliminated
|
||||
@@ -301,7 +301,6 @@ AlterTableAddColumn(const char *relationName,
|
||||
Relation idescs[Num_pg_attr_indices];
|
||||
Relation ridescs[Num_pg_class_indices];
|
||||
bool hasindex;
|
||||
// List *rawDefaults = NIL;
|
||||
|
||||
/*
|
||||
* permissions checking. this would normally be done in utility.c,
|
||||
@@ -386,9 +385,9 @@ AlterTableAddColumn(const char *relationName,
|
||||
/*
|
||||
* XXX is the following check sufficient?
|
||||
*/
|
||||
if (((Form_pg_class) GETSTRUCT(reltup))->relkind == RELKIND_INDEX)
|
||||
if (((Form_pg_class) GETSTRUCT(reltup))->relkind != RELKIND_RELATION)
|
||||
{
|
||||
elog(ERROR, "ALTER TABLE: index relation \"%s\" not changed",
|
||||
elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table",
|
||||
relationName);
|
||||
}
|
||||
|
||||
@@ -429,7 +428,7 @@ AlterTableAddColumn(const char *relationName,
|
||||
0, 0);
|
||||
|
||||
if (HeapTupleIsValid(tup))
|
||||
elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in relation \"%s\"",
|
||||
elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in table \"%s\"",
|
||||
colDef->colname, relationName);
|
||||
|
||||
/*
|
||||
@@ -627,14 +626,12 @@ AlterTableAlterColumn(const char *relationName,
|
||||
/* keep the system catalog indices current */
|
||||
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
|
||||
CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
|
||||
CatalogCloseIndices(Num_pg_attrdef_indices, irelations);
|
||||
CatalogCloseIndices(Num_pg_attr_indices, irelations);
|
||||
|
||||
/* get rid of actual default definition */
|
||||
drop_default(myrelid, attnum);
|
||||
}
|
||||
else
|
||||
elog(NOTICE, "ALTER TABLE: there was no default on column \"%s\" of relation \"%s\"",
|
||||
colName, relationName);
|
||||
|
||||
heap_endscan(scan);
|
||||
heap_close(attr_rel, NoLock);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.55 2000/01/26 05:56:13 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.56 2000/01/29 16:58:34 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,8 +31,8 @@
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
static int checkAttrExists(char *attributeName,
|
||||
char *attributeType, List *schema);
|
||||
static bool checkAttrExists(const char *attributeName,
|
||||
const char *attributeType, List *schema);
|
||||
static List *MergeAttributes(List *schema, List *supers, List **supconstr);
|
||||
static void StoreCatalogInheritance(Oid relationId, List *supers);
|
||||
|
||||
@@ -291,7 +291,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
|
||||
if (!strcmp(coldef->colname, restdef->colname))
|
||||
{
|
||||
elog(ERROR, "attribute '%s' duplicated",
|
||||
elog(ERROR, "CREATE TABLE: attribute \"%s\" duplicated",
|
||||
coldef->colname);
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
{
|
||||
if (!strcmp(strVal(lfirst(entry)), strVal(lfirst(rest))))
|
||||
{
|
||||
elog(ERROR, "relation '%s' duplicated",
|
||||
elog(ERROR, "CREATE TABLE: inherited relation \"%s\" duplicated",
|
||||
strVal(lfirst(entry)));
|
||||
}
|
||||
}
|
||||
@@ -326,9 +326,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
tupleDesc = RelationGetDescr(relation);
|
||||
constr = tupleDesc->constr;
|
||||
|
||||
/* XXX shouldn't this test be stricter? No indexes, for example? */
|
||||
if (relation->rd_rel->relkind == 'S')
|
||||
elog(ERROR, "MergeAttr: Can't inherit from sequence superclass '%s'", name);
|
||||
if (relation->rd_rel->relkind != RELKIND_RELATION)
|
||||
elog(ERROR, "CREATE TABLE: inherited relation \"%s\" is not a table", name);
|
||||
|
||||
for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--)
|
||||
{
|
||||
@@ -353,15 +352,15 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
|
||||
* check validity
|
||||
*
|
||||
*/
|
||||
if (checkAttrExists(attributeName, attributeType, inhSchema) ||
|
||||
checkAttrExists(attributeName, attributeType, schema))
|
||||
{
|
||||
if (checkAttrExists(attributeName, attributeType, schema))
|
||||
elog(ERROR, "CREATE TABLE: attribute \"%s\" already exists in inherited schema",
|
||||
attributeName);
|
||||
|
||||
if (checkAttrExists(attributeName, attributeType, inhSchema))
|
||||
/*
|
||||
* this entry already exists
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* add an entry to the schema
|
||||
@@ -629,11 +628,13 @@ again:
|
||||
heap_close(relation, RowExclusiveLock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* returns 1 if attribute already exists in schema, 0 otherwise.
|
||||
* returns true if attribute already exists in schema, false otherwise.
|
||||
*/
|
||||
static int
|
||||
checkAttrExists(char *attributeName, char *attributeType, List *schema)
|
||||
static bool
|
||||
checkAttrExists(const char *attributeName, const char *attributeType, List *schema)
|
||||
{
|
||||
List *s;
|
||||
|
||||
@@ -641,19 +642,16 @@ checkAttrExists(char *attributeName, char *attributeType, List *schema)
|
||||
{
|
||||
ColumnDef *def = lfirst(s);
|
||||
|
||||
if (!strcmp(attributeName, def->colname))
|
||||
if (strcmp(attributeName, def->colname)==0)
|
||||
{
|
||||
|
||||
/*
|
||||
* attribute exists. Make sure the types are the same.
|
||||
*/
|
||||
if (strcmp(attributeType, def->typename->name) != 0)
|
||||
{
|
||||
elog(ERROR, "%s and %s conflict for %s",
|
||||
attributeType, def->typename->name, attributeName);
|
||||
}
|
||||
return 1;
|
||||
elog(ERROR, "CREATE TABLE: attribute \"%s\" type conflict (%s and %s)",
|
||||
attributeName, attributeType, def->typename->name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.136 2000/01/27 18:11:35 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.137 2000/01/29 16:58:37 petere Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -832,14 +832,14 @@ AlterTableStmt:
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
|
||||
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId /* drop_behavior */
|
||||
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId drop_behavior
|
||||
{
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'D';
|
||||
n->relname = $3;
|
||||
n->inh = $4;
|
||||
n->name = $7;
|
||||
/* n->behavior = $8; */
|
||||
n->behavior = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER TABLE <name> ADD CONSTRAINT ... */
|
||||
@@ -856,7 +856,7 @@ AlterTableStmt:
|
||||
| ALTER TABLE relation_name opt_inh_star DROP CONSTRAINT name drop_behavior
|
||||
{
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'X';
|
||||
n->subtype = 'X';
|
||||
n->relname = $3;
|
||||
n->inh = $4;
|
||||
n->name = $7;
|
||||
@@ -866,7 +866,8 @@ AlterTableStmt:
|
||||
;
|
||||
|
||||
alter_column_action:
|
||||
SET DEFAULT a_expr_or_null { $$ = $3; }
|
||||
SET DEFAULT a_expr { $$ = $3; }
|
||||
| SET DEFAULT NULL_P { $$ = NULL; }
|
||||
| DROP DEFAULT { $$ = NULL; }
|
||||
;
|
||||
|
||||
@@ -2531,19 +2532,15 @@ UnlistenStmt: UNLISTEN relation_name
|
||||
*
|
||||
* Transactions:
|
||||
*
|
||||
* abort transaction
|
||||
* (ABORT)
|
||||
* begin transaction
|
||||
* (BEGIN)
|
||||
* end transaction
|
||||
* (END)
|
||||
* BEGIN / COMMIT / ROLLBACK
|
||||
* (also older versions END / ABORT)
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
TransactionStmt: ABORT_TRANS opt_trans
|
||||
{
|
||||
TransactionStmt *n = makeNode(TransactionStmt);
|
||||
n->command = ABORT_TRANS;
|
||||
n->command = ROLLBACK;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| BEGIN_TRANS opt_trans
|
||||
@@ -2555,19 +2552,19 @@ TransactionStmt: ABORT_TRANS opt_trans
|
||||
| COMMIT opt_trans
|
||||
{
|
||||
TransactionStmt *n = makeNode(TransactionStmt);
|
||||
n->command = END_TRANS;
|
||||
n->command = COMMIT;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| END_TRANS opt_trans
|
||||
{
|
||||
TransactionStmt *n = makeNode(TransactionStmt);
|
||||
n->command = END_TRANS;
|
||||
n->command = COMMIT;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ROLLBACK opt_trans
|
||||
{
|
||||
TransactionStmt *n = makeNode(TransactionStmt);
|
||||
n->command = ABORT_TRANS;
|
||||
n->command = ROLLBACK;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.81 2000/01/26 05:57:07 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.82 2000/01/29 16:58:38 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -57,8 +57,8 @@ if (1) \
|
||||
{ \
|
||||
if (IsAbortedTransactionBlockState()) \
|
||||
{ \
|
||||
elog(NOTICE, "(transaction aborted): %s", \
|
||||
"all queries ignored until end of transaction block"); \
|
||||
elog(NOTICE, "current transaction is aborted, " \
|
||||
"queries ignored until end of transaction block"); \
|
||||
commandTag = "*ABORT STATE*"; \
|
||||
break; \
|
||||
} \
|
||||
@@ -98,13 +98,13 @@ ProcessUtility(Node *parsetree,
|
||||
BeginTransactionBlock();
|
||||
break;
|
||||
|
||||
case END_TRANS:
|
||||
PS_SET_STATUS(commandTag = "END");
|
||||
case COMMIT:
|
||||
PS_SET_STATUS(commandTag = "COMMIT");
|
||||
EndTransactionBlock();
|
||||
break;
|
||||
|
||||
case ABORT_TRANS:
|
||||
PS_SET_STATUS(commandTag = "ABORT");
|
||||
case ROLLBACK:
|
||||
PS_SET_STATUS(commandTag = "ROLLBACK");
|
||||
UserAbortTransactionBlock();
|
||||
break;
|
||||
}
|
||||
@@ -278,17 +278,16 @@ ProcessUtility(Node *parsetree,
|
||||
{
|
||||
RenameStmt *stmt = (RenameStmt *) parsetree;
|
||||
|
||||
PS_SET_STATUS(commandTag = "RENAME");
|
||||
PS_SET_STATUS(commandTag = "ALTER");
|
||||
CHECK_IF_ABORTED();
|
||||
|
||||
relname = stmt->relname;
|
||||
if (!allowSystemTableMods && IsSystemRelationName(relname))
|
||||
elog(ERROR, "class \"%s\" is a system catalog",
|
||||
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
|
||||
relname);
|
||||
#ifndef NO_SECURITY
|
||||
if (!pg_ownercheck(userName, relname, RELNAME))
|
||||
elog(ERROR, "you do not own class \"%s\"",
|
||||
relname);
|
||||
elog(ERROR, "permission denied");
|
||||
#endif
|
||||
|
||||
/* ----------------
|
||||
@@ -335,7 +334,7 @@ ProcessUtility(Node *parsetree,
|
||||
{
|
||||
AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
|
||||
|
||||
PS_SET_STATUS(commandTag = "ALTER TABLE");
|
||||
PS_SET_STATUS(commandTag = "ALTER");
|
||||
CHECK_IF_ABORTED();
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user