Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for transactions #84

Merged
merged 2 commits into from Aug 4, 2017
Merged

Add support for transactions #84

merged 2 commits into from Aug 4, 2017

Conversation

@jesusbagpuss
Copy link
Contributor

@jesusbagpuss jesusbagpuss commented Dec 16, 2016

Fixes #83

Copy link

@graingert graingert left a comment

begin and commit are very common database operations. They don't need signposting with comments

@@ -637,13 +637,17 @@ sub save_data_values
{
foreach my $epid ( keys %{$data->{$date}} )
{
$self->{dbh}->begin; #start transaction if DB engine supports it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment

@@ -230,6 +230,8 @@ sub populate_tables

my $eprintid = $eprint->get_id;

$self->handler->{dbh}->begin; #make all changes in one transaction if DB engine supports them

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment

@@ -257,6 +259,8 @@ sub populate_tables
$display_cache->{$set_name}->{$raw_value} = 1;
}
}

$self->handler->{dbh}->commit; #end transaction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment

Copy link

@graingert graingert left a comment

Any reason you're not using begin_work?

foreach my $value ( keys %{$data->{$date}->{$epid}} )
{
$i = 0;
$sth->bind_param( ++$i, $_ ) for( ( $counter, $epid, $date, $value, ($data->{$date}->{$epid}->{$value}) ) );
$rc &&= $sth->execute();
$counter++;
$counter++;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated whitespace changes

@graingert
Copy link

@graingert graingert commented Dec 16, 2016

Any reason you're using begin over begin_work?

Is there a nice Perl dbi function that does automatic transactions/subtransactions with save points and manages exception rollbacks

@jesusbagpuss
Copy link
Contributor Author

@jesusbagpuss jesusbagpuss commented Dec 16, 2016

Hi @graingert - I tried begin_work when testing this - the method wasn't present.
Digging into the EPrints core, there are begin and commit methods that exist in EPrints::Database - which I assumed were added for a reason (although I'm not sure what reason) - so I used them.

In IRStats2, I think the $handler->{dbh} is not a DBI object (which is why the method doesn't exist).
Can you confirm if this is true for your setup?

@jiadiyao jiadiyao merged commit 0e15cef into master Aug 4, 2017
@jiadiyao jiadiyao deleted the innodb-improvements branch Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants