What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

I'm wondering when exactly a post revision gets created. I can think of two times:

  1. The instant that a post is made three revisions of the original post are created; one for each of the original title, original tags, and original body
  2. The instant a post is edited the original body, title, and tags are saved as a revision?

The thing is, according to Jeff SO saves a version of the post in markdown format in PostHistory table:

The cooked HTML (only) is stored at the Post level, and the raw Markdown (only) is stored in the PostHistory table.

Does this mean that when a post is submitted three objects containing the original tags, body, and title get automatically created?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Have a look at the Data Dump schema. Jeff's comment makes more sense in that context.

Also, your terminology between what's meant by revision and record is confused.

The Posts table stores only the current state of each post (i.e., the latest revision), and the PostHistory table stores information about how a post has evolved (i.e., each record contains part or all of a revision).


Now, revisions. They are created under several circumstances, which apply to all types of posts:

  • You create a post (ask a question, answer a question, create a tag wiki)
  • You edit a post and more than 5 minutes has elapsed since you posted or edited the post *
  • You edit a post where you are not the most recent editor (or owner) of the post
  • You rollback a post to a previous revision (with or without edits)

What gets put in PostHistory for each revision depends on what was changed. For answers and tag wikis, those only have post bodies, so they would get 1 record each. A question, however, is broken down into title, tags, and body, so for each one of those components that was changed, a new record is put in PostHistory (with a suitable revision identifier to group them together).

So, yes, 3 records are created in PostHistory (and 1 in Posts) when you ask a question, but it all constitutes a single revision.

* There is a bug with the in-page retagging tool that always creates a new revision, regardless of the amount of time elapsed since the last edit.

share|improve this answer
    
thanks for the awesome response. A final note: How can the complete markdown version of the post come from the PostHistory table? Since a PostHistory record contains only a part of or a whole revision and not the entire makrdown version of the post (unless I understood this wrong, and the revision stores the entire new version and not only the changes--it's misleading because the post edit history shows you the exact number of characters added and deleted, so I assumed only the changes get saved). –  Mohamad Jan 4 '11 at 18:44
    
never mind. I checked out an example from the data dump and figured it out. It turns out everything is stored. The edit history shows you the difference between the two versions, which is what mislead me to begin with. Thanks again! –  Mohamad Jan 4 '11 at 21:57
    
@Mel: You're welcome! –  Jon Seigel Jan 4 '11 at 22:54
add comment

A post accumulates a revision when there are changes made -- but one 1 revision for changes in a set time period (it feels like 5 minutes).

So you could edit the same post 4 times in 3 minutes and it would 'smash' the changes together into one revision.

Also, no changes are recorded during the first 5 minutes of a post.

share|improve this answer
    
thank you! But how does that explain Jeff's comment about the markdown version of the post? How can they return markdown if the original markdown version is not saved? As he claims, it's saved in the PostHistory table. –  Mohamad Jan 4 '11 at 16:07
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .