Hi. Is there a way to reset the SID to 0? Now that testing is over for one site I am working on, I need to reset back to zero.

Or, do I need to do that in the database. If so, what table and is it as simple as just deleting the latest id or do I delete all submissions to reset back to zero?

Thanks, look forward to suggestions on this.

Comments

quicksketch’s picture

The SID is simply a auto increment column in the "webform_submissions" table. You might try the following (assuming you're using mySQL):

ALTER TABLE webform_submissions AUTO_INCREMENT=1
cdale’s picture

Another way to reset the auto increment column, and delete all existing rows is to use TRUNCATE. (Again, assuming MySQL).

TRUNCATE webform_submissions

waynedrupal’s picture

Thank you.

TRUNCATE webform_submissions,/quote> - that deleted all submissions from all webforms on the site.

Is there a way for each webform to be independant and the SID would be unique to each webform rather than all webforms on site sharing the SID increments?

For examle:

Webform Quote - SID
1
2
3
4

Webform Order - SID
1
2
3
4

The way it is now is like:

Webform Quote - SID
1
4

Webform Order - SID
2
3

quicksketch’s picture

No, this is not currently possible. We'd need to rearrange our database keys in order to change this. Right now the SID is an auto-increment column, we'd need to switch it to a manually generated number to make this support per-webform.

searosin’s picture

It would be great, if the SID would be unique to each webform.

quicksketch’s picture

Status: Active » Closed (fixed)

Closing the original support request.

lionel.a’s picture

Version: 6.x-2.3 » 7.x-3.9
Component: Miscellaneous » Code
Priority: Normal » Minor
Status: Closed (fixed) » Postponed

Hello,
Sorry for coming back with this request, but it is also needed under D7.

The Results / Clear option still doesn't reset SID.

And assuming that there could be several webforms (eg #3), an ALTER TABLE webform_submissions AUTO_INCREMENT=1 could be a mistake (ie, should be after a "clear" operation : ALTER TABLE webform_submissions AUTO_INCREMENT=18 instead of AUTO_INCREMENT=1)

But, as written in the official mysql documentation ( http://dev.mysql.com/doc/refman/5.6/en/alter-table.html ) :

For InnoDB, if the value is less than the current maximum value in the column, no error occurs and the current sequence value is not changed.

In fact, after some tries, setting AUTO_INCREMENT=1 will give the last higher number in the column, plus one.

We should appreciate the webform module including this operation after a "clear" option choice.

ALTER TABLE webform_submissions AUTO_INCREMENT=1

Thanks

quicksketch’s picture

We should appreciate the webform module including this operation after a "clear" option choice.

We can't reset SID to 1 after clearing a single Webform's results, because SID is unique across the entire site, not against an individual Webform node. See #218154: Display serial number instead of SID for a little bit of additional info that might be a better feature request.

lionel.a’s picture

Thank you quicksketch for your reply.
But by altering the table with SID to 1 I meant reseting the autoincrement to the highest value used in the entire site.

This is the InnoDB behavior : when sending the "ALTER TABLE webform_submissions AUTO_INCREMENT=1" query, the SID will get the higher used value instead of 1...

Example :
SID has values from 1 to 58 in different DB tables (Autoincrement value = 59). We suppose when we clear some webform data, the higher SID value is now 43.
Autoincrement value still equals 59.
ALTER TABLE webform_submissions AUTO_INCREMENT=1
Then, the SID autoincrement value equals 44 (example).

Perhaps I have misexplained myself : I don't want to alter all the DB, but only to get the right autoincrement value after a "clear" option.

Thanks.

quicksketch’s picture

Perhaps I have misexplained myself : I don't want to alter all the DB, but only to get the right autoincrement value after a "clear" option.

This would have a very inconsistent behavior. Because SID is shared across ALL webforms on the site, if you had more than 1 webform on the site, clearing the results of one Webform would not be able to reset SID to anything lower than the last submission from any other form.

An example:
- 1000 submissions are made to Webform A. The auto-increment value is now 1001.
- 1 submission is made to Webform B. The auto-increment value is now 1002.
- The results for Webform A are cleared. The auto-increment value is still 1002 (because Webform B uses 1002).

In short, this request is largely bogus. There's no way we can implement such a solution unless SID was per-node. As I've stated in previous issues, a per-node SID would have significant performance repercussions and require a significant rewrite of a lot of Webform's logic, with no real upside other than SIDs are in order for each node.

This request could be compared to requesting that Comment IDs were per-node instead of site-wide. However no one is complaining that comments should be per-node, because it would be ridiculously inefficient to bother with 2 table keys instead of just one. However Comment module does a much better job of making comments appear "in order" on display. So again, I think this is moot point. The only practical solution we're looking at is #218154: Display serial number instead of SID.

lionel.a’s picture

Status: Postponed » Closed (won't fix)

Thanks quicksketch for your explanations,

then I change the status to "closed" (and "won't fix" because it seems altering the whole behavior).
I've previously readed #218154: Display serial number instead of SID, but I am not convinced about this issue.

I understand your example :
- 1000 submissions are made to Webform A. The auto-increment value is now 1001.
- 1 submission is made to Webform B. The auto-increment value is now 1002.
- The results for Webform A are cleared. The auto-increment value is still 1002 (because Webform B uses 1002).

In this case, because of InnoDB behavior, even if you send an "ALTER TABLE webform_submissions AUTO_INCREMENT=1" request, the auto-increment value will still be 1002... (you can try if any dubt).

And if you clear webform B instead of A, then submit an "ALTER TABLE webform_submissions AUTO_INCREMENT=1", auto-increment value will come back to 1001...

That doesn't mean "AUTO_INCREMENT=1" to put 1 into autoincrement value, but to the latest higher value...

Anyway, this request is closed :-)