This will let Class::DBI::Pg deal with tables which have a primary key consisting of more than one column (e.g. CREATE TABLE foo ( a integer, b integer, PRIMARY KEY ( a, b ) ))
Patch sent to author as well, but just in case anyone else is interested . . .
---
/usr/lib/perl5/site_perl/5.8.0/Class/DBI/Pg.pm 2003-09-10 03:59:40.000000000 -0400
+++ Class/DBI/Pg.pm 2004-05-05 13:53:57.000000000 -0400
@@ -23,7 +23,7 @@
WHERE relname = ?)
SQL
$sth->execute($table);
- my $prinum = $sth->fetchrow_array;
+ my @prinums = split(/\s+/, ( $sth->fetchrow_array )[0] );
$sth->finish;
# find all columns
@@ -50,17 +50,17 @@
$sth->finish;
my($sequence) = $nextval_str =~ m/^nextval\('"?([^"']+)"?'::text\)/;
- my(@cols, $primary);
+ my(@cols, @primary);
foreach my $col(@$columns) {
# skip dropped column.
next if $col->[0] =~/^\.+pg\.dropped\.\d+\.+$/;
push @cols, $col->[0];
- next unless $prinum && $col->[1] eq $prinum;
- $primary = $col->[0];
+ next unless @prinums && grep $col->[1] eq $_, @prinums;
+ push @primary, $col->[0];
}
- _croak("$table has no primary key") unless $primary;
+ _croak("$table has no primary key") unless @primary;
$class->table($table);
- $class->columns(Primary => $primary);
+ $class->columns(Primary => @primary);
$class->columns(All => @cols);
$class->sequence($sequence) if $sequence;
}
Found out about scselect yesterday from here. A couple of minutes effort on the train and I now can change from a shell without having to mouse up to the apple menu.
zsh ++
##
## _scselect -- Completion for OS X Network Location utility
##
_scselect () {
local locs
locs=( $( scselect |& \
perl -lne 'next if/^\S/;/\(([^)]+)\)/&&print qq{"$1"}' ) )
_arguments -C "*:Network Location Set:($locs)"
}
Just to save some other person some googling:
Memo to myself: Next OS release bring chair. Mall tile floor is not the most comfortable.
Or at least until that long running wget completes. This will temporarily set the OS X energy saver sleep timer to `never', run the specified command, and then restore the sleep time.
#!/usr/bin/perl
##
## nosleep -- Disable sleep while command runs (OS X)
##
use warnings;
use strict;
my @pm_set_cmd = qw( pmset sleep );
unshift @pm_set_cmd, 'sudo' unless $> == 0; ## Setting needs root privs
## Figure out what sleep's set to
my $old_sleep = undef;
open( GET, "pmset -g live |" ) or die "Can't open pipe from pmset -g: $!\n";
while( <GET> ) {
if(/sleep\s+(\d+)/ ) {
$old_sleep = $1;
last;
}
}
close( GET );
die "Couldn't determine current sleep setting.\n" unless defined $old_sleep;
my $ret;
## Set sleep to 0 (never)
$ret = system( @pm_set_cmd, 0 );
die "Problem setting sleep: @{[ $? >> 8 ]}\n" unless $ret == 0;
## Run command passed as argument
$ret = system( @ARGV );
warn "Problem running command: @{[ $? >> 8 ]}\n" unless $ret == 0;
## Revert to old sleep value
$ret = system( @pm_set_cmd, $old_sleep );
die "Problem setting sleep: @{[ $? >> 8 ]}\n" unless $ret == 0;
exit 0;
__END__
You may wish to add something along these lines to your/etc/sudoers:
Cmnd_Alias PMSET =/usr/bin/pmset sleep [0-9]*
%admin ALL=(ALL) ALL, NOPASSWD: PMSET
Two handy ORA onlamp.com articles you may not have seen:
Now I don't have to remember what box I book marked those on . . .
Last night I bought some socks at a warehouse store because the wife has been complaining about the lack of structural integrity of my present hosiery.
At any rate; 12 pair, 9$US, in a plastic bag. A plastic bag with a recloseable zipper seal.
Socks. In a ziplock bag. This means something. Possibly that ziplock bags are available off the shelf and were the most convenient way to package 12 socks. Or that I should be keeping my socks in the vegetable crisper in the fridge.
All Consuming grobbles throughthe sites listed in weblogs.com for links to books on Amazon and then makes lists of the most blog'd about ones.
See the site for a more complete explanation.
I've now forgotten my headphones at home for the third day in a row. Usually they stay at work, but last week someone was using my office and I was working from home so I took them home. I keep remembering that I've forgotten them when I'm sitting in the car or when I've already gotten to the office.