----- Original Message ----- From: "Alexey Pechnikov"
Newsgroups: gmane.comp.db.sqlite.general
Sent: Saturday, May 08, 2010 2:27 PM
Subject: Re: Returning column to default


Please send to me this patch. I think it may be added to unofficial
http://sqlite.mobigroup.ru repository.

No problems. It should be attached here. If not, send me your email and I'll forward it direct to you. Its created against the latest released version (3.6.23.1)

So that you know, this patch exploits a undocumented/unexpected state in the update column expression. If this expression is set to NULL, then sqlite will crash by default (this is not a problem generally since you can't/don't ordinarily set the expression to NULL). I use this as the indicator to set to default value. It then extracts the default expression from the table column definition and applies it. Note that it must duplicate it since it will later be cleaned up automatically.

If there is no column default then an error occurs ("no default for column: x"). This could easily be changed, if desired, to setting the column as NULL, for example, but to me it makes more sense to have the error.

The attached test file can be placed in the 'test' folder along with all the others and will then run along with them when doing a "make test".

As stated before, I'd be very interested to have feedback on how well it works for you. I can't claim to have tested it exhaustively (e.g. as the test file shows!), but would be happy to augment it and fix any bugs that come up, assuming they're not too complex!!!

Cheers
Andy

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to