Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Monday, November 10, 2008

Mysql Nested transaction

The last time I checked, transaction only supported for InnoDB and BerkeleyDB table format. One thing I didn't know before, that those table format doesn't support nested transaction, you can only do flat transaction that is, you cannot start a new transaction without end/commit previous one. In my case I'm using php pdo extension, everytime i start a new transaction with PDO->beginTransaction() the previous transaction automatically commited.

Simply said it's imposible to use nested transaction using pdo (and maybe most of the php database library) for php.

but from the command line you can however, use mysql savepoint and rollback to savepoint to stimulate nested transactions for example

START TRANSACTION
-- parent sql goes here
SAVEPOINT save_id1
-- nested sql goes here
ROLLBACK TO SAVEPOINT save_id1
COMMIT


hope this would be usefull..

Wednesday, March 05, 2008

Missing days..


Did you know that there are dates that didnt exist ?


For example, there are no dates in year 1752 between Wednesday september 2nd and Thursday 14th in britain. People call this the cutover, it happen when a country decide to switch from Julian to Gregorian calendar, and they have to discard at least 10 days. The first switch happen in 1952, below is the October's calendar of that year











mondaytuesdaywednesdaythursdayfridaysaturdaymonday
1234151617
18192021222324
25262728293031

actually days never missing, its just dates (cant stop thinking bout the people born in those day).The interesting part is, if more than one country switch calendar at the same time, the more days were lost o.O For Indonesia we already use Gregorian Calendar since the proclamation.


You must be thinking i got this info from some website like wiki, or just googling it. Nope! I just read Mysql manual! (lho kok jadi nyambung ke database? Kapan seh gw iseng sengaja nyari info beginian^^)


Yup, mysql engine uses calendar called Proleptic Gregorian Calendar for their DATE or DATETIME values, which assume there are no such event called cutover, for this reason every dates prior the original cutover must ajjusted ie. for russian minus 13 days.


Correct me if i'm wrong, havent read any other reference regarding this, just got really stuck with my insertable view T_T (someone please show me how to work with these brats!)