ProcessUtilityHook DropStmt RenameStmt

From: geohas <lists(at)hasibether(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ProcessUtilityHook DropStmt RenameStmt
Date: 2014-08-11 13:40:29
Message-ID: 53E8C7CD.70008@hasibether.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

I try to catch a DropStmt and convert it to a Rename Stmt, like petere's
pg_trashcan, but i don't like to create new schema. I only like to
rename the table in case of a drop table query.
Is this possible with something like:

ProcessUtility (Node * parsetree,
const char *queryString,
ParamListInfo params,
bool isTopLevel,
DestReceiver * dest, char *completionTag)

{
if (nodeTag(parsetree) == T_DropStmt)
{
DropStmt *stmt = (DropStmt *) parsetree;
if (stmt->removeType == OBJECT_TABLE)
{
RenameStmt *newstmt = makeNode(RenameStmt);
newstmt->objectType = stmt->removeType;
newstmt->newname = new_name;
parsetree = (Node *) newstmt;
}
(*prev_ProcessUtility) (parsetree, queryString, context, params,
dest, completionTag);
}

regards

ge0has
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQEcBAEBAgAGBQJT6MfNAAoJEJFGMlQe7wR/RCQH/1KOwtCLDT2QVrGm/PKfIFGF
e6w+oOCUYz8v78s+uvI5Y5qEuUr2wqYuUhhV7UWXWBwKgLPkSvUTv04TWS9Ms6FJ
+Zn+yzqWUygdwDzKbKY3/qYreYAL6ZBv62ldjtApNUh1VHpPtZsPWtIe/485KB6v
W4xZt7PUAKOUlqTiQwaZok2rdYt0t7vWdVmw6qncUnlPGBpJM/XGGwDl4w5NCK23
Ls5ueLpe8gKoH1eMYG27FKo1rRARVBtB3zPkXmmfRZR+f1FUIkhiDkfm1AYhBJPy
FG0yExArvZjZLQIIEaenb8GzwjR04Ulaqej5CLPdOB0NomkN0aN0CKcSRT9SrME=
=Y3t4
-----END PGP SIGNATURE-----

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2014-08-11 14:40:10 Re: Proposal to add a QNX 6.5 port to PostgreSQL
Previous Message Fujii Masao 2014-08-11 12:59:43 Re: psql: show only failed queries