- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
On Error Raise Frist
Admin
ON ERROR DROP COMMENT
Admin
That programmer should take a look at Vigil. It delivers that functionality out of the box.
Admin
Cheesoid kill self.
Admin
Well, OK, on the next run it deletes my code because I am calling a function that doesn't exist, but it deleted your code first, triggered by my bug.
Vigil's "swear" and "implore" are merely synonyms for a somewhat harsh version of assert, as I'm sure you're all aware.
Admin
You clearly lack the conviction to cope with morally pure code.
Admin
If code fails it is right and proper that it commits Seppuku
Admin
I don't really see a huge problem considering what it's apparently used for. It looks like an automated audit log. What should you do when logging fails? Log it somewhere else instead? How would you consolidate that back into your database properly, especially since a select is required to get the proper data in the first place?
Throwing an error back to the user would also not make sense. Why would you throw an error to the user if the changes they made worked perfectly but you failed to log the fact that they changed things?
Of course a better way to do this would be to handle the audit log in your framework where any query is automatically logged (and in which you can send a message to support if something goes wrong), but lacking that I don't think this is that terrible of a solution.
Admin
Fortunately, in most cases the Catch will fail since in a proper system the calling user won't have permission to drop triggers.
One would hope.
Admin
Your proposal is that the framework could contain no ability to log or neatly customise logging output. If so, I would assert that it indicates another WTF, and one way or another indicates a WTF.
Admin
That's where Oracle clearly beats this amateuristic DB. Whenever you do as much as thinking about a command that vaguely looks like a CREATE, ALTER, or DROP, all triggers are immediately deactivated. Much better.
Admin
"If at first you don't succeed, destroy all evidence that you tried." - Steven Wright
Admin
Admin
This is a corollary in practice: The less code you have, the less bugs you have.
This design pattern embodies self-adjusting code that improves the performance and stability of your system over time!
The event horizon to the birth of SKYNET is nearing ever closer...
Admin
No. Just no.
Admin
The real joke is that the example code is a function called "fib". Perhaps this language could be used to write a program to process Lie groups?
Admin
Coding with Permadeath? I see this as the next big thing.
Admin
That code contains two very serious wtfs:
if that trigger runs into an error then the whole transaction is rolled back. Silently, as it seems. No, not just the audit logging, everything since the last BEGIN TRANSACTION. If that goes undetected by the application, than you are in an inconsistend state between application and database and that is plain wrong.
if the trigger runs into an error it removes itself. If you rely on audit.Account to provide information on changes someone made to his or her account and that trigger is silently removed, than after that your database is basically corrupted, since audit.Account does no longer reflect the changes made.
In a scenario where legal requirements exist to provide a backtrace of a users activity, this sort of error handling can get you neck deep into <insert_material_of_choice>.
Admin
Very lazy. It should at least drop the database, else the data might be corrupted.
Admin
If this is propagated everywhere, even in non-triggers, would this create a cascade delete of all sproc?
Admin
We made the next gen consoles with Diablo 4 in mind. It supports hard-core consoling by default. If they fail to satisfy when performing a function, that functionality is deleted. If they fail too often, they brick.
Admin
On the slim chance that you may be serious and not trolling, allow me to correct you.
Including DDL in an audit trigger that drops itself if it fails is utterly moronic. Just because the software fails to log something doesn't mean it should arbitrarily commit suicide.
Also, failing with an error message when auditing fails is perfectly legitimate and reasonable depending on the application. If audit logging is an important security requirement, you do NOT want the application to continue running silently without it - you want it shouting about the failure and in some instances refusing to continue until it's re-enabled.
The key is in the name - audit log. When you need to actually produce an audit report and find there's no data in there, you would be a little perturbed.
Also DDL inside a trigger is just.. no. Wow. No. Never.
This is the very definition of a terrible solution.
Admin
ROFL.
I commend you for your optimism, sir.
Admin
This looks like T-SQL on SQL Server. I don't have a SQL Server instance handy, but if I recall correctly trying to drop an object while it was executing would just throw an error.
For example on Sybase (which used to share a code-base with SQL Server, and which also uses T-SQL), a procedure which tries to drop itself will yield the error:
Could not execute the statement. Cannot drop the procedure 'TestDropProc' because it is currently in use. Sybase error code=3702 Severity Level=16, State=1, Transaction State=0 Line 5
Admin
Thats just a standard samurai code - in case of an error, the only honorable think to do is to commit seppuku.
Admin
Admin
The top bit of your left pinky should be sufficient.
Admin
Forget self-modifying code, meet self-destructive code.
Admin
That's not petrol, Cheesoid!
Admin
Can anyone deconstruct what it's attempting to do BEFORE it commits seppuku if it fails?
Admin
I support this self-destruct pattern and would encourage many, many of my colleagues to implement it in their code if possible.
CAPTCHA: iusto give a damn.
Admin
Version control your database schema.
That is all.
Admin
It's like FuckItJS for databases.
Admin
Cut the member who dishonor you.
Admin
This code pattern might actually save IE, or... Windows even!!!
Admin
Admin
This pattern will be known henceforth as "Seppucode"
Admin
Admin
I prefer code which deletes itself upon success . See, e.g. "trap door" and other cool ways to wreck a perfectly good Vacation Destination Featuring Dinosaurs. The original book, not the movie.
Admin
Admin
If at first you don't succeed, destroy all evidence that you tried
Admin
Admin
Also using a DB that allows you to put DDL inside a trigger is just no. Wow. No. Never.
This is the very definition of a terrible database.
Seeing as if it's allowed lots of people will do it, no matter how stupid 'it' is.
Admin
On Error Raise Fist
Admin
I can not see single use for the DROP Trigger. Also will DB allow you to delete an object from itself?
Admin
TRWTF is that the calling object probably never began a transaction, so this exists only because the ROLLBACK TRANSACTION fails and the DROP TRIGGER never executes.
Admin
On error raze trigger.
Admin
Kinda falls into the category of:
"Make love not war".
Admin
Because the author was apparently f&*#$d in the head?
Admin