Re: [RDBO] RFC: Moving from SourceForge to Google Code

2008-02-19 Thread Perrin Harkins
On Feb 19, 2008 11:04 AM, John Siracusa <[EMAIL PROTECTED]> wrote:
> Anyone have any
> opinions or experiences to share?

It's great.  Fast svn, easy wiki, easy bug tracking, good mailing list
support, no waiting for project approval.  I recommend it.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] using MySQL's FOUND_ROWS() feature with QueryBuilder

2008-02-14 Thread Perrin Harkins
On Thu, Feb 14, 2008 at 4:06 PM, Ken Prows <[EMAIL PROTECTED]> wrote:
>  Sorry, I forgot to include the limit arg in my example. I do use limit
>  so that I can page the data. I need to know the total matches so that I
>  can determine how many pages there are.

In that case, I recommend that you avoid FOUND_ROWS.  It's almost
always worse than a second COUNT query.  Try it in the mysql shell and
see.

http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] using MySQL's FOUND_ROWS() feature with QueryBuilder

2008-02-14 Thread Perrin Harkins
On Thu, Feb 14, 2008 at 3:30 PM, Ken Prows <[EMAIL PROTECTED]> wrote:
> I am trying to find a way to use MySQL's FOUND_ROWS() feature with Rose:
>
>  
> http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
>
>  I am most interested in getting this to work with my Manager classes so
>  that I do not have to do a second query to find the total count using
>  the 'get_objects_count' method.

Usually people want to do this because they're using LIMIT, but it
turns out to be a bad idea.  It's usually faster to do a second COUNT
query than to use LIMIT and FOUND_ROWS.

Since you are not using LIMIT, I don't think you need SQL_CALC_FOUND_ROWS.

"In the absence of the SQL_CALC_FOUND_ROWS  option in the most recent
SELECT  statement, FOUND_ROWS()  returns the number of rows in the
result set returned by that statement."

Try calling FOUND_ROWS() without SQL_CALC_FOUND_ROWS and see if it
works.  (Kind of seems like you should be able to get this from DBI in
some way too, but I think $sth->rows only works for
INSERT//UPDATE/DELETE.)

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] ANNOUNCE: Rose::DB 0.739

2008-02-08 Thread Perrin Harkins
On Feb 8, 2008 1:43 PM, John Siracusa <[EMAIL PROTECTED]> wrote:
> * Caching of db objects during mod_perl server start-up is now turned
>   off by default, with new API to turn it back on and do the necessary
>   pre-fork clean-up that this entails.  This change solved a segmentation
>   fault problem triggered in DBD::Informix when database handles created
>   in the parent were not properly disconnected prior to the first fork of
>   the apache process.

You will probably have to close the handles before forking, or at last
set InactiveDestroy, no matter which database you're using.  Even if
you never use those handles again, they will eventually time out and
may break your new handles on the server side when they do.  I've seen
this happen in forking code with MySQL handles.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] suggestions for enchancement

2007-11-28 Thread Perrin Harkins
On Nov 27, 2007 11:21 PM, David Lloyd <[EMAIL PROTECTED]> wrote:
> Ron Savage wrote:
> > You mean like SQL::Abstract?
> > http://search.cpan.org/~nwiger/SQL-Abstract-1.22/
>
> I was thinking the same thing...does that not do what the OP wishes it to?

SQL::Abstract is very limited.  It doesn't even handle joins.  The
query builder class already in RDBO supports a lot more capabilities
of SQL than SQL::Abstract does.

- Perrin

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] suggestions for enchancement

2007-11-27 Thread Perrin Harkins
On Nov 27, 2007 2:41 PM, maxim <[EMAIL PROTECTED]> wrote:
> its useful when you have XML based framework where your backend is
> trying to reflect some XML schema and you dont what to remap XML on the DB
> schema but just using it.

If you really want to use XML for your backend storage, I'd suggest
using something built for that purpose like XML::Comma or a database
with XML support.  MySQL 5.1 has built-in XPath queries, and I'm sure
someone must have built a Postgres extension for it too.  Oracle has
had it for about a decade.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] suggestions for enchancement

2007-11-27 Thread Perrin Harkins
On Nov 26, 2007 11:39 PM, John Siracusa <[EMAIL PROTECTED]> wrote:
> I suppose you could simulate it by building
> up Perl data structures suitable for passing in a get_objects() query
> parameter (i.e., value/hashref pairs and so on) but that's not quite
> the same thing.

That's what I've done and it's been fine so far.  A simple object
wrapper for that sounds nice though.

Replacing SQL with a different query syntax doesn't sound very useful
to me.  It just makes it harder to debug your queries.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Wanted: Perl programmers (Boston, MA)

2007-11-19 Thread Perrin Harkins
On Nov 14, 2007 10:31 AM, John Siracusa <[EMAIL PROTECTED]> wrote:
> We use
> mod_perl, Informix, MySQL, an MVC web application framework, and (of
> course :) Rose::DB::Object and Rose::HTML::Objects.

When is the Rose web framework coming to CPAN?  I'm ready for it.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] cached DBI handles

2007-10-26 Thread Perrin Harkins
Hmm, why not use DBI->connect_cached for this?

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Profiling SQL queries

2007-09-29 Thread Perrin Harkins
On 9/29/07, Richard Jones <[EMAIL PROTECTED]> wrote:
> Is there an equivalent to the Catalyst DBIC::Profiler available for
> Rose? I'm looking for something to output SQL query timing in the
> browser.

DBI::Profile and the DBI tracing options should give you what you
want.  They work with any database layer built on top of DBI.

- Perrin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-17 Thread Perrin Harkins
On 8/17/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> But really, I'd like to solve this somehow so the default way works as
> well.  It would be nice if I could ask Apache::DBI not to call
> reset_startup_state(), perhaps by passing a special connect attribute:

Do you think that Apache::DBI should be doing this on every connect
call to begin with?  I suppose it depends on whether it is trying to
provide safety for ported CGI scripts, or a general purpose persistent
database connection.  Now that DBI->connect_cached is widely
available, the need for Apache::DBI to be a general purpose tool is
reduced.

Actually, that might be a simple fix for this:  If you call
DBI->connect, Apache::DBI would do what it does now.  If you call
connect_cached, it would skip the reset call.  What do you think?
(And yes, connect_cached gets handled by Apache::DBI if it is loaded.)

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Perrin Harkins
On 8/15/07, Graham Barr <[EMAIL PROTECTED]> wrote:
> So either init_dbh needs to be able to detect that the $dbh it gets is a
> reuse of an existing connection, or Rose::DB->new needs to return the same
> object for all calls for the same connection.

Even if init_dbh is changed, I think Apache::DBI 1.06 is doing the
same thing on every call to connect(), so that probably also needs to
change.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-15 Thread Perrin Harkins
On 8/15/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Well, I didn't switch AutoCommit on or off and I didn't do a rollback
> myself, so the question remains why the default configuration with
> Apache::DBI and init_db(MyApp::DB->new) does a rollback when the
> database is accessed from a new db (in the helper) though this db should
> share the dbh with the db I do the begin_work and commit on.

I have a guess.  Looking at the new code in Apache::DBI, I see that it
now tries to reset the state of the $dbh every time you call
connect().  This probably breaks the begin_work() state.

I'm not sure why this was added, since it seems like this only needs
to happen in the cleanup handler, not on every connect call.  I'll
talk to the maintainer about it.

Meanwhile, try commenting out the call to reset_startup_state() in
your Apache::DBI source and see if that fixes the problem.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> I looked for that and didn't see it, and still don't see it.

Sorry, this was actually changed already.  I was looking at an older release.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> Doesn't Apache::DBI just care that $dbh->{AutoCommit} is false at the
> time it checks in the cleanup handler?

Look further up in the code.  It never pushes the handler unless
AutoCommit is off.  Probably a mistake in my opinion.  If others
agree, I'll submit a patch to change it.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> The simplest way to do this is to leave everything as per the
> defaults, and just use Apache::DBI.

Note that Apache::DBI also does the automatic rollback for you, but
only if you have AutoCommit off when you connect.  If you connect with
AutoCommit on, you have to handle the rollback yourself.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Only question: Is it really possible to call rollback as a class method
> or do I have to call it on the specific object that started the transaction?

You have to call it on the database handle that started the
transaction.  If all of your objects  (within the same request) use
the same database handle, there is no difference.  A rollback affects
everything on that database connection.

> >> How do I manipulate the "isolation level"?
> >
> > It depends on your database.  What database are you using?
>
> SQLite, but if at all possible I would set it in some generic way with
> RDBO because I might well change the database in the future.

Since the syntax can vary a bit from one database to another, there
isn't a truly generic way to do it.  I don't use SQLite, but there's
some information on how to set this on the pragma page:
http://www.sqlite.org/pragma.html

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Well, my understandig was that if perl dies within a transaction it (or
> DBI) would do a rollback, from your answer I guess this is not the case.

No.  Your database will do it if you cut the connection and there is
uncommitted work, but perl or DBI won't do a rollback just because you
called die.  Remember, in a persistent environment like mod_perl, die
doesn't stop the perl interpreter or cut the database connection.

> > automatic rollback in a cleanup handler when running mod_perl.
>
> do you have any pointer on how this is done (correctly)?

   $r->push_handlers(PerlCleanupHandler => sub {
   MyApp::DB->rollback();
   });

I don't know what the proper way to get a database handle is in your
setup, but all you need to do is get one and call rollback.

> How do I manipulate the "isolation level"?

It depends on your database.  What database are you using?

> I thought the begin_work would set it as it should be.

It should start a transaction, but isolation level is a higher-level concept.
http://en.wikipedia.org/wiki/Isolation_level

> And to the second alternative, how do I have to setup RDBO with mod_perl
> to share a db (and dbh with it) for everything within one
> process/request but not across multiple processes?

Unless you open a handle during server startup and try to keep it, it
will not be shared between processes.  There could be something going
on with your closure stuff there if you do that during startup.  The
more likely answer though is that you just have your database in a
"READ UNCOMMITTED" (aka dirty read) isolation level and the handles
are not shared.

I will leave it for someone else to comment on the way you're managing
your database handles because I don't have enough first-hand
experience with what you're doing there to give you good advice.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Perrin Harkins
On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> my $db = MyApp::DB->new;
> $self->my_db($db); # a new db for a new transaction
> $db->begin_work;  # Start transaction
>
> ... create two objects and save them ...
>
> die "Does it roll back?";
> $db->commit;

I don't see any rollback there.  It's a common practice to put an
automatic rollback in a cleanup handler when running mod_perl.
Another approach is to catch exceptions and issue the rollback there.
If you did one of those, this would work.  Otherwise, I don't see how
you expect it to get rolled back.

> Edit: It is even more mysterious: The saved records are only there as
> long as apache isn't restartet. I tried clearing the cache, calling the
> records in different ways, no matter they are there. After a restart
> they are not. It looks as if the rollback is not done at the "die" of
> the script but the 'kill' of the server ?!?

That implies that they aren't committed either, and that you are
running with a "dirty read" isolation level that lets you see data
that hasn't been committed yet on other database connections.  Either
that, or you are somehow using the same connection in multiple
processes, which would be very bad.

- Perrin

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] cache object for later use within a mod_perl request cycle

2007-06-22 Thread Perrin Harkins
On 6/22/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> I didn't get a result. Within the authentication handler I stuffed an
> object (or even a simple string) into $r->pnotes and tried to write it
> to the logfile from the authorization handler but it was empty, the
> same test worked with $c->pnotes.

I'm guessing that one of these was actually a subrequest, so you might
need to use $r->main() to get the top-level request.

> (Perhaps off list because it seems to be more of a mod_perl problem
> rather than RDBO)

Probably.  I think that what you have will work, but if you have other
questions about this kind of thing bring them on over to the mod_perl
list.

- Perrin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] cache object for later use within a mod_perl request cycle

2007-06-22 Thread Perrin Harkins
On 6/22/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Thanks for the hint! This almost did it. Some tests showed that I had
> to use the connection-variant of pnotes in my setup:
>
> use Apache2::ConnectionUtil;
> # grab the connection object;
> my $c = $r->connection;

You really shouldn't need to do that.  What made you think $r->pnotes
wasn't working?

- Perrin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] cache object for later use within a mod_perl request cycle

2007-06-20 Thread Perrin Harkins
On 6/20/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
> Is this possible? I tried $r->dir_config(user_obj => $rdbo_user_obj); from 
> the mod_perl
> documentation but that didn't work.

I think you're looking for this:
$r->pnotes(user_obj => $rdbo_user_obj);

- Perrin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-16 Thread Perrin Harkins
On 4/16/07, Tim Bunce <[EMAIL PROTECTED]> wrote:
> > If there's an exception, I believe DBI issues a rollback automatically,
>
> Nope.

Yes, I was looking at the DESTROY code, not the error handling code.

I was talking to Bill about this off-list and he showed me a case
where my strategy fails.  It doesn't properly roll back on non-DBI
errors.  I have to play around with it more to find a solution that
handles that without losing the automatic scoping feature of local
AutoCommit.  More on this later.

Sorry for the incorrect advice!

- Perrin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-14 Thread Perrin Harkins
On 4/14/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
> So when that die is called the transaction is rolled back and nothing
> sub outer() or do_stuff_and_send_mail() did is in the database.  But,
> the mail still got sent (probably saying something happened that
> didn't.)

It sound like you want a way to make non-transactional things outside
of the database transactional, so that the entire request succeeds or
fails.  There used to be a whole category of software dedicated to
this, called TP Monitors.

I usually keep database transactions as short as possible to help
concurrency, so I wouldn't wrap a whole request in a transaction.  The
need for that depends on your application.

> That's why it might make sense to stuff things like sending mail onto
> an array in the stash to run if there's no exceptions.

That sounds like a decent compromise between complexity and risk.  A
more complicated approach would be to write (or find) a transactional
API for all the things you want to do, e.g. an e-mail class that
doesn't actually send until it gets a commit().  In some cases, the
object can keep track of what it did and provide a rollback() method.
It's a heavy approach, and a lot of work.

I still don't think this has much to do with nested database
transactions though :)  You could hit the same issue with one
transaction or no database at all.

- Perrin

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-13 Thread Perrin Harkins
On 4/13/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
> Catalyst does wrap the requests in eval, so if a controller dies you
> have to look for the exception stuffed int $c->errors somewhere
>
> If you don't mind doing a rollback on all requests then that sure
> makes things nice and simple.  Thanks.

The rollback seems to be pretty cheap when no changes have been made,
so I think it's a reasonable solution.  It's what Apache::DBI has done
for years.

> To avoid running code that you only want to happen if the transaction
> commits.  For example, sending an email.
>
> If you have one sub:
>
> do_stuff_and_send_mail {
>
> {
> local $dbh->{AutoCommit} = 0;
> $object->do_stuff;
> } # commit (unless nested)
>
> send_mail( "do_stuff happened!" );
> }
>
> Obviously, the mail won't be sent if there's an exception.  But, if
> do_stuff_and_sent_mail() is called from code that's in a transaction
> (nested transaction) then send_mail can happen, and after the sub
> above returns an exception would roll back the entire transaction.
> But send_mail() still already sent the mail.

I think I'm starting to see the problem.  It's not nested transactions
that are an issue for you, it's nested exception handling.

In my system, the code above will never run send_mail() if there's an
exception.  It will throw the exception, nothing will catch it, and
I'll get a stack trace in my log (thanks to Carp) and a pretty error
page sent to the user (thanks to apache), and my cleanup handler will
do a rollback.  It sounds like you're thinking of a situation where
that block is really an eval, and after doing a rollback, you just
continue.  I simply don't do that.  I only catch exceptions when I
intend to try to correct them and continue the request, which is what
you're saying you want to avoid here.

One option for you is to re-throw the exception outside the eval block
(I like how easy Exception::Class makes that), but that does beg the
question of what the eval block was there for in the first place.  I
suspect it was there to make sure a rollback happens, which a cleanup
handler already takes care of.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-13 Thread Perrin Harkins
On 4/13/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
> So, for example, in Catalyst in an end() (or something at the end) you
> would look for errors and then do a rollback, otherwise commit?  And
> you look at AutoCommit to see if you need to do either of those, I
> assume.

No, it's much simpler than that.  Maybe Catalyst complicates things
with some extra eval wrapping.  In my CGI::Application app, I just
turn on RaiseError.  If nothing goes wrong, the changes get committed
when I exit the block with AutoCommit turned off.  There's no need for
an explicit commit.  (And because I use local $sbh->{AutoCommit}, it
won't commit until I leave the highest level block that initiated a
transaction, so it amounts to fake nested transactions but with
automatic scoping.)

If there's an exception, I believe DBI issues a rollback
automatically, and I have a rollback at the end of every request just
in case, like Apache::DBI does.  I don't currently have any cases
where I try to rollback and continue the request, so I don't trap the
exceptions.

> In general I like to get in, get the transaction done and get out
> because I might have a longer task that follows and don't want the
> transaction left open during that time.

My transactions are as small as possible, to avoid holding locks.  I
only use longer ones in bulk loading situations where it makes a big
difference.  I'm not really following why the fake nested transactions
help with this.

> Perhaps a cleaner way (other than queuing up the task for an external
> process) would be push a sub onto an array with the code to run after calling
> commit.

Sorry, I'm not sure what problem you're trying to solve there.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-12 Thread Perrin Harkins
On 4/12/07, Peter Karman <[EMAIL PROTECTED]> wrote:
> here's my (admittedly buggy) code for doing this. It caches a single dbh for
> each unique RDB registry entry combination of domain.type.dsn. I know that it
> breaks under mod_perl -- anyone spot why? (the error I get is from Pg: 
> "prepared
> statement 'dbdpg_1' already exists" after first request, because %cache seems 
> to
> be shared across all apache child processes).

My guess is that your code connects to the database from the parent
process in order to do auto-discovery of the tables, and then you end
up sharing the same handle when apache forks.  Apache::DBI does
prevent this, so you might consider using that instead, or else add $$
to your dbh key.  Most of what you have here is covered by either
Apache::DBI or DBI->connect_cached, except that alarm part.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] dbh caching

2007-04-12 Thread Perrin Harkins
On 4/12/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
> Speaking of transactions -- anyone ever asked for nested transaction
> support?

We had a semi-long discussion about that a few weeks back, which you
can find in the archives.

> > > What about using Ima::DBI?  Would that stomp on RDB?

You'd probably be better off just using DBI->connect_cached.  There's
no real advantage to Ima::DBI that I can think of.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Possible to use load() to get a exclusive lock???

2007-04-11 Thread Perrin Harkins
On 4/11/07, John Siracusa <[EMAIL PROTECTED]> wrote:
> If you db supports it, you could try going into a serialized isolation
> mode and then doing all your operations in a single transaction.

It does.  "SET TRANSACTION ISOLATION LEVEL repeatable read" will cause
all of your SELECT statements to be SELECT... FOR UPDATE until you
change it back.

However, it's usually better to do this kind of thing with an atomic update:

UPDATE seq SET count = count + 1 WHERE name = 'foo'

If you want that value back, you can grab it like this:

UPDATE seq SET count = LAST_INSERT_ID(count + 1) WHERE name = 'foo'
SELECT LAST_INSERT_ID()

This is actually almost identical to the example from the
documentation for the LAST_INSERT_ID function.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Best way to do multiple calls to database

2007-03-29 Thread Perrin Harkins
On 3/29/07, James Masters <[EMAIL PROTECTED]> wrote:
> Mod Perl sounds very tempting
> but doesn't sound like it works too well with win32; Had enough
> trouble getting Rose working on win32 - spent days on it!

I don't use Windows myself, but the Win32 packages that Randy Kobes
supports for mod_perl are top notch.  There are definitely people
using them.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Transactions, ACID etc.

2007-03-16 Thread Perrin Harkins
On 3/16/07, Christopher H. Laco <[EMAIL PROTECTED]> wrote:
> But doesn't that act of using a raw dbh from inside of a model, defeat
> the purpose of models/MVC to begin with?

Well, now you're getting into what MVC means and how it gets
implemented by systems like Catalyst.  I think the "controller" in
Catalyst is part of the model, and the only actual Controller is
Catalyst itself.

O/R mappers are quite a bit further down below MVC.  "Model" is a
high-level concept encompassing all interactions with your data model.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Transactions, ACID etc.

2007-03-16 Thread Perrin Harkins
On 3/16/07, Christopher H. Laco <[EMAIL PROTECTED]> wrote:
> So, I have my Cat models all
> provide commit() and rollback().

I wouldn't do that.  This is a function of your database connection,
not of individual row objects.  DBI already provides commit/rollback,
and that's the level where it should stay.

> Now, I want to use my models outside of Catalyst, let's say in a perl
> script. Now I have to write yet another block of code to do monitor
> success/failure, and call commit()/rollback().

Sure you have to call commit -- it's a new set of database
interactions, with possibly different commit points.  Monitoring
success is usually pretty easy with RaiseError turned on.

> Now, I can wrap my models in yet another wrapper to do what the cat
> controller and the perl script just didbut now that model is unaware
> about the script that uses IT. Now I have to write more code, to call
> the code to call commit/transaction. And so on an so forth.

You totally lost me on that one.

> It just seems like with all of the
> ORMS out there and all of the ways to use 'schema classes' from them,
> doing transactions in levels (or multiple levels above) is clumsy at best.

I assume you're talking about the faked multiple levels of commit that
DBIx::Class provides.The simplest answer is to just stay away from
all that stuff.  Do the commits yourself, at the highest level.  Keep
it out of your O/R mapper objects.

The longer answer is that since nothing but my own code ever touches
transactions in my environment, I make rules that allow me to write
reusable code.  I keep all of it out of my O/R tools.  I turn
AutoCommit on.  When I'm in a high-level routine and I want to make
several operations transactional, I turn it off with local
$dbh->{AutoCommit}. If I want to reuse that code from a context where
a transaction might be active already, it nests perfectly.

I expect you could do something similar with DBIx::Transaction,
although it sounds more manual to me.  And yes, you'll have to get
your hands on the dbh.  No way around that.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Transactions, ACID etc.

2007-03-16 Thread Perrin Harkins
On 3/16/07, Christopher H. Laco <[EMAIL PROTECTED]> wrote:
> My point is, there's no sane way to do a big jumble of code in one DB
> transaction without having to go code diving for a dbh to work against,
> ala 'local $dbh->{AutoCommit} and such.

So you're saying that one of your tools is trying to do automatic
commits for you.  Which one?

> If I'm working in a Catalyst app, and I need $c->model('DBModuleOne')
> and $c->model('DBModuleTwo') to do some work, and both either commit or
> rollback, I have to do module diving to get at each models dbh and write
> mode transaction management code.

Those database objects shouldn't be handling transactions.  They are
too low-level for that.  Methods above them that you write should do
all of the transaction handling.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Transactions, ACID etc.

2007-03-16 Thread Perrin Harkins
On 3/16/07, Christopher H. Laco <[EMAIL PROTECTED]> wrote:
> Totally a side tangent, but when you start using your schema classes
> from RDBO/DBIC/CDBI in things like Catalyst as Models, and maybe using
> many of them at the same time in one transaction, that whole "Just use
> the dbh" falls apart.

In what way?  Do some of these try to commit transactions for you?
Class::DBI doesn't.

>   ## Some function way above DBI
>   DBI::Transaction->start;
>
>   $rdboclass->delete(...);
>   $otherdbiclass->add(...);
>   $dbicclass->update(...);
>
>   DBI::Transaction->commit;

Still not getting it.  DBI supports this almost exactly.

> I just lothe having to dig into individual modules to get a dbh to do a
> transaction, or even use helper methods.

Can't help you there.  If you want to talk to the database, you need a
dbh.  This is where the incompatibilities that I'm aware of lie:
sharing a dbh between multiple O/R mappers can get tricky because they
each have different expectations about how it will be created and what
the default settings are.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Transactions, ACID etc.

2007-03-16 Thread Perrin Harkins
On 3/16/07, James Masters <[EMAIL PROTECTED]> wrote:
> Just wondering - does Rose deal with transactions, rollbacks etc. "under the
> hood" (or "under the bonnet" as we say in England) and is therefore ACID
> compliant?

You really don't need any help from your object-relational mapper to
use transactions  -- you can just call commit or rollback on your
database handle.  However, Rose has convenience methods that wrap
these functions.  If you search the documentation for "transaction"
you should find what you're looking for.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Unexpected column defaults in MySQL

2007-01-17 Thread Perrin Harkins
On Wed, 2007-01-17 at 17:33 -0500, John Siracusa wrote:
> I was ignoring strict mode for the purposes of this exploration.  Even
> in "crazy old MySQL mode" I think the "describe table" output should
> more closely match what's returned by DBD::mysql in COLUMN_DEF.

I agree, that sounds like a bug in DESCRIBE to me.  Maybe they are
justifying it by saying that this is an automatic system-wide default,
rather than a column-specific one, but it's still misleading.

- Perrin


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Unexpected column defaults in MySQL

2007-01-17 Thread Perrin Harkins
On Wed, 2007-01-17 at 10:01 -0500, John Siracusa wrote:
> I'm forwarding this private email thread to the list with the
> permission of the (now anonymized) sender because it's about an
> unexpected situation that many RDBO users may face.  Yes, it revolves
> around yet another fun feature of MySQL/DBD::mysql.  How did you
> guess? :)

Hmm.  It sounds like the problem was that he marked some columns NOT
NULL but wanted them to accept NULL.  When MySQL is not in strict mode,
that causes the columns to use generic defaults when passed NULL, hence
the column_info data from DBD::mysql saying that this column defaults to
empty string.

The best thing to do is to run MySQL 5 or later with strict mode
enabled, so that trying to put NULL into a NOT NULL column will be a
fatal error (like it is in most databases).  That makes it obvious where
the problem is.

- Perrin


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Known Issues Between RDBO, Apache2::Reload, and ModPerl::PerlRun?

2007-01-15 Thread Perrin Harkins
On Mon, 2007-01-15 at 16:00 -0500, Robert James Kaes wrote:
> So, a different error, but still an error when I touch the file.

Sorry to say it, but not all modules work with Apache2::Reload.  There
is no official way to reload a module in perl, so all it does is delete
the module from %INC, load it again, and hope for the best.  It often
works, but modules that do a lot of auto-generation can be problematic.
The things that always works is restarting apache.

- Perrin


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] client out of memory with large table

2007-01-07 Thread Perrin Harkins
Tim Bunce wrote:
> Just to be clear on this: The *DBI driver* does not do that.
> 
> For MySQL the underlying db client library does that by default.
> (I think that's also true for Postgres.) Oracle client libs default to
> prefetching one extra row but DBD::Oracle tells it to prefetch about two
> ethernet packets worth.

Apologies, Tim.  My DBD::Oracle expertise is out-of-date.  I remember 
needing to fiddle with the prefetch settings to deal with large result 
sets at etoys.com, but that was some 8 years ago and we might well have 
created that problem ourselves through our attempts to improve the 
common case of small queries.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] client out of memory with large table

2007-01-05 Thread Perrin Harkins
John Siracusa wrote:
> Finally, if you only want to turn this on for particular calls, remember
> that the db is an optional argument to all Manager methods.  You can always
> make/get a $db, yank out the $dbh, set the attribute manually, and pass the
> $db as a parameter to your Manager calls.
> 
> $db = My::DB->new(...);
> $db->dbh->{'mysql_use_result'} = 1;
> $iterator = MalwareLog::Manager->get_blah_iterator(db => db, ...);

I recommend doing it this way, and turning it off after your large 
query, unless this is essentially a single user reporting database. 
When you turn on mysql_use_result and do a query on a MyISAM table, it 
will keep a read lock on the table until you finish with that statement 
handle.  This is not an issue with InnoDB tables because they use 
multi-version concurrency control (MVCC), so readers never block writers.

If all you use it for is reports, and you don't need to handle 
concurrent updates, then it doesn't matter and you can just leave it on 
all the time.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] client out of memory with large table

2007-01-05 Thread Perrin Harkins
Jonathan Vanasco wrote:
> i simply don't know of anyone handling large  
> amounts of data with mysql and NOT having several dedicated staff to  
> deal  with mysql and data integrity alone.

Now you do.  We have multiple databases with 80 million+ row tables, no 
dedicated DBAs, and no data integrity problems.  InnoDB's integrity 
constraints work just fine.

You guys are just going to have to get over it: MySQL works.  Note that 
I'm not bashing Postgres -- it works too.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] client out of memory with large table

2007-01-05 Thread Perrin Harkins
Randal L. Schwartz wrote:
> Anyone using MySQL these days is for one of two reasons:
> 
> 1) Legacy
> 2) Ignorance
> 
> Both of those are curable.

There's no cure for speed, flexibility, and ease of use though. :)

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] client out of memory with large table

2007-01-05 Thread Perrin Harkins
Neal Clark wrote:
> Ideally, I will be making iterators from SQL calls. The SQL will  
> limit the number of rows as best as I can, but there will be times I  
> need to iterate over every row. I read in one of the CPAN docs that  
> Rose::DB::Object::Iterator returns 'true iterators', i.e. the rows  
> are not loaded until you call next

The DBI drivers for most databases (and this includes Postgres and 
Oracle) will load the entire result set into your local machine's RAM 
even before you fetch the first row.  With MySQL and Oracle, you can 
tell them not to do this.  With Postgres, I think you have to use cursors.

For MySQL, just do this before issuing your large query:
$dbh->{'mysql_use_result'}=1;

You probably want to set it back afterward, since the default is better 
for small queries (it frees up resources on the server faster).

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] How to do locking with RDBO?

2006-12-05 Thread Perrin Harkins
Jonathan Vanasco wrote:
>   lock table
>   read last_used_number( year )
>   increment last_used_number( year )
>   unlock table

This can also be done in a one-shot, without needing to explicitly lock 
anything:

UPDATE foo SET id = id+1 WHERE 

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] How to do locking with RDBO?

2006-12-05 Thread Perrin Harkins
Michael Lackhoff wrote:
> Though it seems to slightly defeat the point in using 
> RDBO: To have Perl, classes and methods instead of SQL, tables and 
> columns.

Abstraction is certainly one reason to use an ORM, but I think it's a 
bad idea to stick strictly with your ORM if it prevents you from using 
your database inefficiently.  In this case, the difference in efficiency 
and amount of code required is pretty big.  You can wrap this SQL up in 
a method that will hide it from the calling code.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] How to do locking with RDBO?

2006-12-05 Thread Perrin Harkins
Michael Lackhoff wrote:
> I need some pseudo-unique numbers like invoice numbers. They start every
> year with 1, so autoincrement won't work. My idea was to use a helper
> table with just just two fields 'year' and 'last_used_number'. Is it
> enough to create a two column unique key or would it be better to do
> something along these lines:
> - lock table (or row?)
> - read last_used_number for the year
> - increment it
> - save
> - unlock
> 
> Is there an idiom for this kind of task?

You can usually do this kind of ++ thing in one INSERT...SELECT statement:

INSERT INTO invoice (id) SELECT MAX(id)+1 FROM invoice;

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] RDBO and Storable?

2006-12-05 Thread Perrin Harkins
Peter Leonard wrote:
> Rose::DB::Object::Cached would be a likely choice, except we're looking 
> at a multi-server cache - as Jonathan mentioned above, memcached is our 
> intended target.

Sure, but it's probably easier to modify the storage part of 
Rose::DB::Object::Cached to hit memcached than it is to start from scratch.

Incidentally, in my tests, memcached wasn't faster than MySQL at simple 
primary key fetches.  You might get the same result by just replicating 
your db and using the slave for your reads.

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] RDBO and Storable?

2006-12-04 Thread Perrin Harkins
Peter Leonard wrote:
> I understand the complexity involved, and what we're looking for is the 
> quick storage & retrieval of the underlying data

It sounds like you want to cache the data.  Did you consider expanding 
Rose::DB::Object::Cached to use your data storage of choice instead of 
memory?

- Perrin

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Prepared Statements?

2006-08-09 Thread Perrin Harkins
On Wed, 2006-08-09 at 01:38 -0400, Jonathan Vanasco wrote:
> if so, does it DEALLOCATE the statement handle?

Won't that be the same as just turning off server-side statement
handles?

- Perrin


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


[RDBO] PATCH: in-lined values for IN without binds

2006-08-04 Thread Perrin Harkins
Hi,

Here's a patch that fixes a problem with how IN queries are handled when
bind values are not used.  It was flattening scalar refs into strings
rather than de-referencing them, but only when binds are off.

I tried to follow your indentation style.  I shifted the bind variations
around a bit because it led to a bunch of duplicated code otherwise.
Couldn't figure out where this should go in the test suite, but if you
point me at something that does it for the binds I could try writing a
test for it.

- Perrin
--- /home/perrin/Desktop/Rose-DB-Object-0.742/lib/Rose/DB/Object/QueryBuilder.pm	2006-07-21 14:15:50.0 -0400
+++ lib/Rose/DB/Object/QueryBuilder.pm	2006-08-04 19:41:32.0 -0400
@@ -597,48 +597,48 @@
 {
   if($op eq '=')
   {
-if($bind)
+my @new_vals;
+
+foreach my $val (@$vals)
 {
-  my @new_vals;
+  my $should_inline = 
+($db && $col_meta && $col_meta->should_inline_value($db, $val));
 
-  foreach my $val (@$vals)
+  if($should_inline || $force_inline)
   {
-my $should_inline = 
-  ($db && $col_meta && $col_meta->should_inline_value($db, $val));
-
-if($should_inline || $force_inline)
-{
-  push(@new_vals, $val);
-}
-elsif(ref $val eq 'SCALAR')
-{
-  push(@new_vals, $$val);
-}
-elsif(defined $val)
+push(@new_vals, $val);
+  }
+  elsif(ref $val eq 'SCALAR')
+  {
+push(@new_vals, $$val);
+  }
+  else
+  {
+if($bind)
 {
-  push(@$bind, $val);
-  push(@new_vals, $placeholder);
+  if(defined $val)
+  {
+push(@$bind, $val);
+push(@new_vals, $placeholder);
 
-  if($bind_params)
+if($bind_params)
+{
+  push(@$bind_params, $col_meta->dbi_bind_param_attrs($db));
+}
+  }
+  else
   {
-push(@$bind_params, $col_meta->dbi_bind_param_attrs($db));
+push(@new_vals, 'NULL');
   }
 }
 else
 {
-  push(@new_vals, 'NULL');
+  push(@new_vals, $dbh->quote($val));
 }
   }
-
-  return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', @new_vals) . ')';
 }
 
-return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', map 
-   {
- ($force_inline || ($db && $col_meta && $col_meta->should_inline_value($db, $_))) ? 
- $_ : $dbh->quote($_)
-   }
-   @$vals) . ')';
+return "$field " . ($not ? "$not " : '') . 'IN (' . join(', ', @new_vals) . ')';
   }
   elsif($op =~ /^(A(?:NY|LL)) IN (SET|ARRAY)$/)
   {
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


[RDBO] QueryBuilder and literal SQL values

2006-07-21 Thread Perrin Harkins
I'm using the QueryBuilder from some of my code, and it has been working
quite well.  I have a case where the behavior surprised me and I'm
wondering if I misunderstood the docs.

The docs show this:
query => [ legs => { gt_sql => 'eyes' } ]

This results in "legs > eyes" with no quoting.  However, if "legs" is
something other than a column name that the QueryBuilder knows, it just
gets silently dropped.  My impression from the docs was that this would
allow me to put arbitrary functions and such in here, like this:

query => [ '1+1' => { sql => '2' } ]

Of course I can use the clauses option to get around this, but I'm just
wondering if this should have worked as I expected.  Also, it would be
very nice if columns that don't match could cause a fatal error instead
of being silently dropped.  I will see if I can make a patch for that if
you agree.

- Perrin


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Timezone & Date localization, best practices?

2006-07-12 Thread Perrin Harkins
John Siracusa wrote:
> "The time zone of the DateTime object that results from a successful parse
> is set to the value of the time_zone option, if defined. Otherwise, it is
> set to the server_time_zone value of the object's db attribute using
> DateTime's set_time_zone method."

Nice feature.

> In the absence of any explicit action (e.g., a setting a server_time_zone()
> on your db objects) DateTime objects will "pass through" RDBO as-is.  That
> simplifies things significantly.  IME, it's best to store all dates in the
> db in a single time zone and then convert to the user's time zone when
> displaying the dates.

Agreed, but that usually means you should specify a time zone for 
DateTime objects.  Otherwise, you can get into a lot of trouble using 
the floating time zone if you try to do any comparisons with epoch times 
or MySQL TIMESTAMP columns.

- Perrin


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


[RDBO] Rose::DB::Object::QueryBuilder set operations

2006-06-06 Thread Perrin Harkins
Hi,

I'm looking at using Rose::DB::Object::QueryBuilder on its own (without 
the rest of RDBO) to generate some SQL.  It looks like this should work 
fine.  However, I'm finding the in_set and in_array methods very confusing.

According to the docs, 'COLUMN' => { in_set => 'A' } generates the SQL 
"A IN COLUMN".  This seems like the reverse of normal usage, e.g. "name 
IN ('john','paul')".  Can anyone explain what this might be used for?

Also, what is the difference between "IN" (in_set) and "= ANY" 
(in_array)?  According to all the database docs I've seen, these are 
equivalent.

Were these meant to be used for subqueries?  I do intend to work with 
subqueries and am thinking about how to incorporate them or else cheat 
with some post-processing.

- Perrin


___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] column default values

2006-05-25 Thread Perrin Harkins
On Thu, 2006-05-25 at 14:24 -0400, Guillermo Roditi wrote:
> is it really? because I couldn't figure it out. I dont want to use
> timestamps, and I dont know how to do it otherwise

Timestamps parse to DateTime objects as easily as datetime columns do.
This is what I use:
timestamp TIMESTAMP NOT NULL DEFAULT NOW()

That will put in a value on insert but will not change it when you
update the row later.

- Perrin



---
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] column default values

2006-05-25 Thread Perrin Harkins
On Thu, 2006-05-25 at 13:26 -0400, Guillermo Roditi wrote:
> Basically the promblem is that I want default for a column to be
> NOW(). unfortunately that is getting insterted as -00-00  so my
> guess is that it's getting screwed up in the placeholder stage, and I
> can't just do default => DateTime->now... so i thought of doing
> default => sub {return DateTime->now; }  

Is there some reason why you don't want to just have the database do
this for you automatically?  It's easy to do in MySQL.

- Perrin



---
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Catalyst::Model::RDBO ?

2006-03-09 Thread Perrin Harkins
On Thu, 2006-03-09 at 19:00 -0300, Nilson Santos Figueiredo Junior
wrote:
> The main point really is code clearness and structure. It's an MVC
> framework and you're asking the model to do its job (the same happens
> to the view). It's really a thin wrapper, but a thin wrapper that
> guarantees that everything works well within the framework (such as
> using the central configuration file).

I still think the $c->model() method looks like a layer of indirection
with no added value (attempting to abstract things that can't be
abstracted), but I agree that the central configuration file could be
useful.

- Perrin



---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Catalyst::Model::RDBO ?

2006-03-09 Thread Perrin Harkins
On Thu, 2006-03-09 at 00:11 -0300, Nilson Santos Figueiredo Junior
wrote:
> You get one nice thing, though: $c->model('Artist') (where $c is the
> Catalyst context object) returns the appropriate object for the
> "Artist" model.

I never understood the point of this.  That code just replaces the name
"My::App::Artist" or similar.  It seems like an attempt to make model
classes interchangeable without modifying the driving code, but they're
really not interchangeable.  You can't swap one made with
Rose::DB::Object for one made with Class::DBI without changing lots of
code.

> I think the main thing really is the Helper class provided along with
> the models, which provide scaffolding so you're up and running as
> quickly as possible using that model.

People do seem to like that, at least to see some example code.  Also,
the central configuration seems like a possibly useful feature.

- Perrin



---
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] RDBO::Manager->get_objects in list context

2005-12-22 Thread Perrin Harkins
On Thu, 2005-12-22 at 09:54 -0500, John Siracusa wrote:
> On 12/22/05 10:04 AM, Uwe Voelker wrote:
> > Manager's get_objects unconditionally returns "[EMAIL PROTECTED]", whereas 
> > the
> > doc says it respects list context (and I vague remember it did some
> > releases ago).
> 
> The docs are wrong, but I've changed my mind on this a few times.  Opinions?

I hate wantarray.  It's a constant source of bugs and makes testing more
complicated.  I prefer methods that consistently return the same thing.

As an example, I've had to debug problems like this for my co-workers a
few times with Class::DBI:

my @foo = Bar->search(baz => 1) || die "no baz found";

That will not give the list context return, but rather the scalar
return, which is an iterator in Class::DBI.  This is just the tip of the
iceberg.

- Perrin



---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Re: [T2-users] Adding Tangram my ORM benchmark suite

2005-12-19 Thread Perrin Harkins
On Mon, 2005-12-19 at 18:35 -0500, John Siracusa wrote:
> If the number of iterations is fixed, you get a usable wallclock time in the
> results.

The danger here is that cmpthese does not use that, so the compare
option is misleading.  I got bitten by that once, assuming that
the :hireswallclock option would change what cmpthese compares.

> Anyway, the fact that working around the feature/performance deficiencies of
> a particular ORM is "common practice" is hardly a convincing endorsement :)
> In the particular case of fetching related objects, many ORMs do include
> this feature, and users like it and use it.

I completely agree.  That's why I brought it up -- I'm interested in
seeing the performance penalty (in extra queries) that Class::DBI has in
this regard highlighted.

- Perrin



---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Re: [T2-users] Adding Tangram my ORM benchmark suite

2005-12-19 Thread Perrin Harkins
On Mon, 2005-12-19 at 17:30 -0500, John Siracusa wrote:
> Pass the "--time" and (optionally) the "--hi-res-time" flags to bench.pl to
> see a wall clock comparison.

Are you sure?  I looked at Benchmark a while back trying to find a way
to measure wall time with cmpthese() and couldn't find one.  I don't
think it does wall time comparisons in the iterations/second stats.

> Anyway, the way the bench is designed, the i/o wait and other db overhead
> should be exactly equal for each ORM . They're all using the same db, and
> they all have their own private subset of rows, in an attempt to defeat OS
> and db caching effects across ORMs.

The thing I had in mind here is how some of them make more fetches than
they ideally should for complex queries, which is a major source of
performance drain in Class::DBI.  I suppose it's hard to tell what
should be measured here, since complex queries in Class::DBI typically
mean hand-coded SQL or else manipulation in Perl, and anyone concerned
about performance would probably choose the former.

- Perrin



---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object


Re: [RDBO] Re: [T2-users] Adding Tangram my ORM benchmark suite

2005-12-19 Thread Perrin Harkins
On Mon, 2005-12-19 at 08:33 -0500, John Siracusa wrote:
> Yes, the db itself will usually be the biggest performance drain.  But the
> point of this benchmark suite is to isolate the overhead caused by the ORM
> itself.

Aren't unnecessary extra queries the biggest source of overhead though?
That seems worth measuring to me.  Now I'm thinking maybe this benchmark
should measure wall time instead of CPU as well.  That would make extra
queries carry a higher penalty.

- Perrin



---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
___
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object