/* * DropErrorTable * * Drop the error table from the database. This function will be called from * destroyCdbSreh when an autogenerated error table was not used in the COPY * operation granted KEEP wasn't specified. * */ static void DropErrorTable(CdbSreh *cdbsreh) { StringInfoData dropstmt; RangeVar *errtbl_rv; Insist(Gp_role == GP_ROLE_DISPATCH); ereport(NOTICE, (errcode(ERRCODE_SUCCESSFUL_COMPLETION), errmsg("Dropping the auto-generated unused error table"), errhint("Use KEEP in LOG INTO clause to force keeping the error table alive"))); initStringInfo(&dropstmt); appendStringInfo(&dropstmt, "DROP TABLE %s.%s", quote_identifier(get_namespace_name(RelationGetNamespace(cdbsreh->errtbl))), quote_identifier(RelationGetRelationName(cdbsreh->errtbl))); errtbl_rv = makeRangeVar(get_namespace_name(RelationGetNamespace(cdbsreh->errtbl)), RelationGetRelationName(cdbsreh->errtbl), -1); /* DROP the relation on the QD */ RemoveRelation(errtbl_rv,DROP_RESTRICT, NULL, RELKIND_RELATION); /* dispatch the DROP to the QEs */ CdbDoCommand(dropstmt.data, false, /*no txn */ false); pfree(dropstmt.data); }
/* ---------------- * general utility function invoker * ---------------- */ void ProcessUtility(Node *parsetree, CommandDest dest) { char *commandTag = NULL; char *relname; char *relationName; char *userName; userName = GetPgUserName(); switch (nodeTag(parsetree)) { /* ******************************** * transactions * ******************************** */ case T_TransactionStmt: { TransactionStmt *stmt = (TransactionStmt *)parsetree; switch (stmt->command) { case BEGIN_TRANS: commandTag = "BEGIN"; CHECK_IF_ABORTED(); BeginTransactionBlock(); break; case END_TRANS: commandTag = "END"; EndTransactionBlock(); break; case ABORT_TRANS: commandTag = "ABORT"; UserAbortTransactionBlock(); break; } } break; /* ******************************** * portal manipulation * ******************************** */ case T_ClosePortalStmt: { ClosePortalStmt *stmt = (ClosePortalStmt *)parsetree; commandTag = "CLOSE"; CHECK_IF_ABORTED(); PerformPortalClose(stmt->portalname, dest); } break; case T_FetchStmt: { FetchStmt *stmt = (FetchStmt *)parsetree; char *portalName = stmt->portalname; bool forward; int count; commandTag = "FETCH"; CHECK_IF_ABORTED(); forward = (bool)(stmt->direction == FORWARD); /* parser ensures that count is >= 0 and 'fetch ALL' -> 0 */ count = stmt->howMany; PerformPortalFetch(portalName, forward, count, commandTag, dest); } break; /* ******************************** * relation and attribute manipulation * ******************************** */ case T_CreateStmt: commandTag = "CREATE"; CHECK_IF_ABORTED(); DefineRelation((CreateStmt *)parsetree); break; case T_DestroyStmt: { DestroyStmt *stmt = (DestroyStmt *)parsetree; List *arg; List *args = stmt->relNames; commandTag = "DROP"; CHECK_IF_ABORTED(); foreach (arg, args) { relname = strVal(lfirst(arg)); if (IsSystemRelationName(relname)) elog(WARN, "class \"%-.*s\" is a system catalog", NAMEDATALEN, relname); #ifndef NO_SECURITY if (!pg_ownercheck(userName, relname, RELNAME)) elog(WARN, "you do not own class \"%-.*s\"", NAMEDATALEN, relname); #endif } foreach (arg, args) { relname = strVal(lfirst(arg)); RemoveRelation(relname); } }