squirrel icon indicating copy to clipboard operation
squirrel copied to clipboard

Rewrite stmt cache for transactions

Open devsergiy opened this issue 10 years ago • 16 comments
trafficstars

Implements stmt cache for transaction

Reason of rewrite: Prepared statements should be created on transaction. So cache should be created with using transaction as Preparer

Test will be added soon. Waiting for any suggestions

devsergiy avatar Jan 28 '15 14:01 devsergiy

I'm trying to be very careful about backwards compatibility in this library, and this change removes an existing interface. I'm probably happy to add your new interface and implementation, but not at the expense of breaking the existing one.

lann avatar Jan 28 '15 16:01 lann

Other than backwards compat (and minor comment on your inline example) this looks good to me.

lann avatar Jan 28 '15 16:01 lann

Hi @lann

I didn't find examples of use existing DBProxyBeginner interface. What was intent of DBProxyBeginner interface and NewStmtCacheProxy method? At first sight it looks like creating cache for transactions, but it will not get perfomance improvement from transactions. Or we should use transaction as preparer for builders by hands? But in this case this interface has no sense

So how would be better to adopt existing interface or create a new one?

devsergiy avatar Jan 28 '15 17:01 devsergiy

DBProxyBeginner is exported, so any external project that calls NewStmtCacheProxy could be assigning to a variable with that explicit interface type. Removing the interface from squirrel would break that external code.

lann avatar Jan 28 '15 17:01 lann

@lann redo commit as adding new interfaces.

I have one concern about starting transactions on NewStmtCacheTransactionProxy. On the one hand this method should be used only when you need a transaction, but maybe would be better always start transaction by hands and add note that any call to Exec(), QueryRow etc. should be wrapped in cache.Begin() cache.Commit() to be cached for transaction?

devsergiy avatar Jan 28 '15 18:01 devsergiy

That's a good point. What if it went directly to the DB by default, and then swapped in the transaction when the user calls Begin and swap back to the DB on Commit/Rollback?

lann avatar Jan 28 '15 18:01 lann

@lann Hi, I've updated pull request and added fallback to StmtCacher when we don't star the transaction

devsergiy avatar May 26 '15 12:05 devsergiy

Unfortunately I will not be able to review or merge major changes for the forseeable future; see README.

lann avatar Jul 29 '15 04:07 lann

Lann has moved Squirrel to the Masterminds project, and is still the architect, but @mattfarina and I will be helping him maintain. We'll start reviewing pull requests and see if we can get this in.

technosophos avatar Jul 29 '15 16:07 technosophos

@technosophos Sure, will update PR in case of any issues

devsergiy avatar Jul 29 '15 16:07 devsergiy

Is this going to be addressed, by any chance?

matteosuppo avatar Oct 14 '19 13:10 matteosuppo

@matteosuppo I've proposed this long time ago, I could revisit this to make build green

@technosophos will u be able to do a review after that?

devsergiy avatar Oct 16 '19 17:10 devsergiy

@technosophos will u be able to do a review after that?

@spetrunin I am (back to) maintaining this project now. I will review this again if it is updated.

lann avatar Oct 16 '19 19:10 lann

@spetrunin are you still working on fixing this?

stampy88 avatar Oct 06 '20 18:10 stampy88

@stampy88 didn't use squirrel for a long time but could fix a build for this pr:)

devsergiy avatar Oct 06 '20 19:10 devsergiy

I would also find this useful!

2opremio avatar Jan 20 '23 00:01 2opremio