rlucas.net: The Next Generation Rotating Header Image


Oregon Lottery Video Poker Specific Numbers

Executive Summary:

– I examine one Oregon Lottery video poker machine's reports over a circa three-year period.

– The “loss rate” for a brisk player at most games is $27 per hour, nearly four times the minimum wage.

– The “house edge” on most games is over five times worse than that with e.g. craps or blackjack.

– Players do react rationally though imperfectly to varying hold
percentages (house edge), and preferentially play games with a smaller
hold (smaller house edge).

– A bar with the legal limit of five such machines would net (EBIT)
nearly $39000 annually, with the state keeping the other $100,000.

– The lottery in effect pays $310 per square foot per year to rent bar
space, a 1000% premium over the downtown central business district.

– These numbers are below the statewide average, which is likely skewed by some very high-volume locations.

(Some numbers have been rounded to fit annual time frames.)

This machine had ten normal games, of which all had a 10% hold, except
one with 6% (“Flush Fever”) and one with 8% (“Oregon Gold”).  The
“draw high” game is 0% hold (no house edge).

Contrast this with ~5.3% for roulette, ~1.5% for craps, and ~1-2% for blackjack.

By far the most money was played on “Flush Fever,” the game with
the lowest hold.  This is probably because the difference between
a 10% hold and a 6% hold is so dramatic, that even without labeling, a
player can detect it readily.  About 45% of the action (money
played) was at this game. “Jacks or Better” got about 12% of the
action.  With 8% and 7% respectively, were “Deuces Wild” and
“Oregon Gold” (the 8% hold game). 

Since there are ten games, and the #1 and close #4 games are the least
and second-least holding games, we can surmise that people play more at the lower hold games.

Previously, I had speculated that the least you would expect a player to lose
under a 10% hold, playing one 25-cent game every ten seconds (brisk but
not blazing) would be $9 an hour. In fact, nearly all games recorded an
average bet of 75 cents or more.  That means that the hourly loss
rate would be at least $27 an hour, an hourly rate equating to a full-time salary of
$54,000 a year.

In fact, the overall hold percentage is reduced by two facts: 1.
players preferentially play the less-biased games, and 2. an
even-money, “double or nothing” bet with no house edge is offered to
winning hands.  The overall theoretical hold for the machine as
played should have been 6.37%, though it lagged slightly with only 5.8%
actually held.

Of the cash that had, over three years, been fed into the machine, more
than half is denominated in $20s (the largest).  About $267,000 in
bills had been put into the machine.  About $184,000 in winning
tickets had been printed.  Although on each coup the player might
expect 90% back, for every buck actually put in the machine, only 69
cents come back out.

The machine in question had about $1.4 million in action put through it
over 3 years (recall, action is calculated each bet, so it will be many
multiples of cash drop).  The total hold was about $83,000, about $2300 a month (one machine), or
about 5.8% of action (the “draw” game counts toward action, but cuts
down on the hold percentage since it has no inherent advantage).

How much play did this box get?  With an 83 cent average bet, and
476,400 dollars put through a year, that's about 574,000 bets per
year.  That's about 1752 a day, or 131 an hour through a 12-hour
day.   This sanity-checks my 360/hour estimate — 1/3 of the
time in rapid play seems sane.

The bar had five video lottery machines (the legal limit), but only one
of them was kind enough to tell us its financial history.  To
situate it, it's a youngish, dive-y 20s and 30s bar, with pool tables, the kind
of place where a cuba libre costs less than 4 bucks and they don't call
it a “cuba libre.”  In those terms, the patrons of that bar could
have had another 21,000 cubas libres over the last three years instead
of playing video poker.  This is not “el primo” territory for
video poker, though I would guess they do OK by video poker standards.

To do some quick math:
5 machines * 89000/year/machine = $445000 / year / bar drop
5 machines * 27667/year/machine = $138335 / year / bar hold
Retailer commission (average, per Oregon Lottery) 28% = $38733 / year / bar hold

To get $38733 annually, risk free, at 2% interest, you'd need
nearly a cool $2 million in the bank.  What does the retailer
stake for this?  About 25 square feet per machine, including chair
space.  With five machines, that's 125 square feet generating
$38733, or $310 / sq ft / year.  Today in Portland, Oregon's
largest city, you would be hard presesed to find Class A office space
renting for more than $30 / sq ft / year.  So the rental rate that
the Lottery is paying dive bars is only a 1000% premium over that for a
suite in Portland's toniest skyscraper.

To bring it back to earth, let's sanity check all of this against the known figures:

circa 2100 retailers * $138335 / year / retailer = $290 M hold overall

This is in sanity-range with the lottery's published $530 M figure
(there tend to be a few top-performers in the video lottery that skew
the results to the high end).

This could be an interesting case study for anyone looking at the
recently-again-in-the-news issue of Oregon's video lottery. 
Unfortunately, nobody is talking about how we can mitigate the harms;
instead, everybody just wants to wring more money out of the program.

INFO: What happens to ssh every 2:11:15?

I was getting a weird artifact in my logs.  A daemon process that was in charge of keeping an ssh connection open to a remote host was restarting ssh every two hours eleven minutes:

myuser 15208 0.0 0.0 0 0 Z 02:01 0:00 [ssh <defunct>]
myuser 15511 0.0 0.0 0 0 Z 04:12 0:00 [ssh <defunct>]
myuser 15548 0.0 0.0 0 0 Z 06:24 0:00 [ssh <defunct>]
myuser 15584 0.0 0.0 0 0 Z 08:35 0:00 [ssh <defunct>]
myuser 15619 0.0 0.3 3408 1704 S 10:46 0:00 ssh -T myhost ...

What the heck is going on? I was running this from behind a DSL modem, and I had experienced some intermittent problems with it before. Was it the modem? Googling on the model # indicated nothing similar reported by others. Was it my ISP or Telco? Phone calls to them indicated that 2 hours was the median time between dropped connections for some old modems, but not mine and not my circuit type. Hmm. Many people pointed to the TCP KeepAlive default of 7200 seconds — two hours — but my problem had a period of over two hours. Almost exactly, consistently, two hours eleven minutes.

As it turns out, the TCP KeepAlive time of 7200 seconds plus the default KeepAlive probe interval (75) times the default probe count (9) add up to 2:11:15.

If you want to change this for one reason or another, try:

echo "30" > /proc/sys/net/ipv4/tcp_keepalive_time

… or likewise (remember that you'll still have 11:15 worth of probe * count; lower those too if you need to know sooner). Better yet, read http://av.stanford.edu/books/tcpip/tcp_keep.htm for some actual theory on the subject.

One good use for this information is if you want to keep a persistent connection open between two machines using, e.g., Net::SSH::sshopen2 for a bidirectional remote connection to a process executed on a remote machine, but you're on a kind of flaky connection that can cause the connection to get dropped often but briefly, and the nature of the stuff you're doing is such that you want it to re-connect and try again rather than obliviously sit through the blip.

(The reason I ramble so lengthily on what particularly one might use this for is because you do NOT want to follow these directions if you're having a more common “momentarily flaky” connection sequela, such as you have terminal sessions that you wish to keep open despite a moment of flakiness — in that case, you do NOT want to enable short TCP keepalives, since they are really “detect deads,” and they will increase the likelihood that your blip in the connection will kill your terminal session.  In that case, you pretty much want to do the OPPPOSITE of this, excepting that 1. if you are behind a NAT router and your connection isn't actually flaky, you might really be seeing a timeout of the NAT table, not connection flakeage, and so you DO want to put a keepalive in shorter than the NAT table timeout [it's all a bit much, isn't it?] 2. you are probably best off just using “screen” and doing a screen -r to reconnect to an old screen when you get reconnected [screen is awesome for all sorts of reasons, and wth screen, if you can divorce yourself from the graphical burden, you've essentially got a total multitasking virtual desktop with persistent state as long as you've got a vt100 terminal].)

The way I would recommend would be the following:

1. Set up your local ssh_config to make sure you're using KeepAlive yes.

2. Set up your local tcp settings to have a short keepalive time and probe interval/count.  (Some kernels apparently don't behave with less than 90 seconds as the keepalive time but I have had success with much lower numbers.)

3. Set up your remote sshd_config to use the ClientAliveInterval and ClientAliveCountMax with reasonable values.  What this does is sort of a reverse and in-band version of what the TCP keepalive is doing on the local machine; the ssh daemon will send an encrypted signal across every ClientAliveInterval seconds and will hang up the connection if it misses CountMax of them in a row; this makes sure that the process you run on the remote machine gets hung up OK.

4. Make sure that your sshopen2 call and the sending and receiving of things along it recognizes when the SSH connection gets closed out and deals with it, such as by an eval loop and a reconnection in the event of $@ .


Oregon Lottery Video Poker Hold / EV statistics

This posting has three parts:

I. Why video lottery is a bad thing for the state to run
    in which I describe philosophical and practical problems with the status quo.
II. What the state doesn't tell about the mechanics of video lottery
    in which I describe the key statistical
metrics of how deleterious the game itself is, which metrics are not
published by the state.
III. My proposed scheme for remedying the situation.
    in which I indulge myself with presumed legislative fiat.

It will in turn be followed (preceded, for those of you reading in LIFO
order on the main page) by specific information hinted at in section II.

I. Why video lottery is a bad thing for the state to run.

Video poker (video lottery) as run in Oregon is deplorable for a number of reasons:

1. It uses a state-enforced monopoly to dole out “free money” to the private sector at the whim of the lottery administrators.
    A. No innovations, goods, or services are required
of lottery “retailers” — the machine is in effect an artificially
scarce rent-producing box.
    B. Unlike in a public-private collaboration such as
a utility, where the public (through the state) gives rights-of-way and
monopoly in exchange for the pulic good of universal power and
communications accessibility, the private portion of the video poker
cartel (bars) brings nothing to the table except access to drunk people
with cash.
    C. Giving free rents to qualifying and willing bars
in this manner dramatically disorts the economics of bar ownership,
subsidizing poor management of properties (it is not unusual that a bar should “break even”
on honest revenues, and make the annual profit from video lottery) and
penalizing bars whose morals or decorum make video lottery unacceptable.

2. It figuratively “addicts” the state budget to its revenues, giving itself institutional inertia.
    A. Video lottery sales comprise the lion's share of
lottery sales ($530 M / $895 M in FY 04), making the video lottery the
sine qua non of the entire operation.  (The portion of sales from
video lottery will rise dramatically as “line games” — slot machines
— are added.)
    B. The net transfers to the state in excess of $364
M  make for 3% of the state's budget.  This does not include
an effective “slush” fund of carry-forward earnings.  Legislators
must account for this gap if they take anti-lottery measures,
effectively hobbling forward-thinking lawmakers.  Job and
entitlement cuts that would follow budget cuts due to lottery rollback
give the lottery allies in the powerful public-employee unions.
    C. The lottery uses its earnings, before paying the
state its dividend, to pay for aggressive public-relations campaigns to
ensure its institutional lifespan.  If Republicans are afraid of
having to “starve” state-perpetuated “beasts,” this one is
truly fearsome.

3. It literally addicts gamblers, and constitutes a massive regressive wealth-transfer system.
    A. The video lottery is faster and more addictive
than paper lottery tickets; in fact, Oregon video lottery now
officially includes “line games,” or slot machines.  For more on
the addictiveness of the video lottery in South Carolina, see
    B. By reducing the need for a higher or more
progressive income tax, the video lottery subsidizes the highest-income
Oregonians.  (Not that we need to be paying particularly higher
income taxes, mind you, but there you have it.)

4. WORST OF ALL: Video lottery is the least transparently-treated part of the whole lottery scheme.
    A. The lottery commission emphasizes the paper
ticket games on its web site and its PR campaigns.  In fact, the
“ticket” lottery sales (excluding keno, multistate, and sports) amount
to less than 22% of sales — the vast majority comes from video lottery.
    B. The lottery publishes frequency charts and odds
of winning for the various ticket games, but publishes little about the
video lottery machines.
    C. Nowhere are the rules, EV / hold, and frequency audits of the video poker machines published. 

On the flip side, however, there are lots of things to like about the video lottery:

1. It gives money to the state budget.
[2. Some folks like to play it for fun.]

How can any principled person like the video lottery?  Religious
folks should hate it because it's gambling.  Liberals should hate it because it's regressive in
its redistribution and because some people have fun with it. 
Conservatives should hate it because it “feeds the beast” and teaches
fiscal irresponsibility, and because some people have fun with it. 
Libertarians should hate it because it's a state-violence-enforced
monopoly in what should be a competitive market and therefore people
aren't free to have fun with it on their own terms.  Humanists
should hate it for its fostering of antisocial behavior and its
reduction of human potential to negative-sum lever-pressing
domapinergic repetition.

II. What the state doesn't tell about the mechanics of video lottery.

What do I mean when I talk about “hold” or “EV?”  These are
measurements of the “edge” in a game (hold being the house edge), or,
from the player's perspective, the Expectation Value, given as portion
of amount wagered to be received back on each trial on average (note
that EV is typically stated less the initial unit bet, e.g. starting at
0, giving a positive or negative figure, -.05 instead of .95.  I
prefer EV given with 1.00 instead of 0 as a starting place, for ease in
the types of calculations I prefer.  If you are using the normal
method, simply subtract 1 from the EV numbers I use).

A quick primer on EV: for every $1 you bet, how much will you make
back, on average?  With a perfect coin-toss, it's $1 in, $1 out —
50/50 odds, or a 1.00 EV.  If the coin were biased to heads by 1%,
then your $1 bet on tails would win $0 [or “lose”] 50.5% of the time,
and win $2 only 49.5% of the time, giving you a 0.99 EV.  EV under
1 is considered “negative,” while the rare chance for a positive EV bet
is one in which the EV is greater than 1, also known as “getting the
best of it.”  Representative EVs include: roulette (American)
.947, blackjack ~.98, craps (pass line) .985, coin toss, 1.00, a year
in a savings account, ~1.01, a year
in the US equity markets, ~ 1.07.  Remember, EV is calculated with
each and every bet, like compound interest, so a .99 EV game done for
100 trials should net you back only 0.37 of your money (though in
reality variance messes up that neat figure).  Contrast that
with 100 years in the stock market at 7% [1.07 EV], which should give
you 867 times your money back, less taxes.  The total amount bet *
the number of bets is “action;” if you bet $5 100 times, you put $500
in action through, even though you may only have ever had $25 to play
with.  The “hold” is1-EV, or the percentage of each bet that the
house gets back; because it's calculated on each trial, the house
expects to earn the “hold” times the “action.”  Got it?

Poker players, stat jockeys, and others with a sense of EV will appreciate this chart from the Oregon Lottery's
annual report FY 2004:

The Lottery had the highest sales
years ever in each of the following categories:
Total Lottery Sales:                   $895.18 million

Video Lottery Sales:                 $530.97 million

Total Traditional Sales:              $362.30 million

Keno Sales:                             
$116.48 million

Powerball Sales:                      
$  45.97

Sports Action Sales:                 $  10.00 million

At the bottom is Sports Action — a game that is technically beatable
(positive EV) if you are an expert handicapper.  Then comes
Powerball, a game that is rarely, but occasionally, positive EV because
it is progressive (if nobody wins, the jackpot can theoretically get
large enough to give a positive return).  Then comes Keno and
“traditional” — the stuff that most people think of when “lottery” is
said — all negative EV games but transparently so.  But almost
all the money, in reality, comes from video lottery — video poker (and
soon slots) — about which almost no information can be found.

Note that video poker can be positive EV — in a competitive market
like Las Vegas, where 1. operators have an incentive to reduce the hold
(increase the EV) and 2. progressive jackpots exist that, when unwon,
can boost the EV to positive.

Why, gentle reader, am I spouting off about the corrupt lottery system?

The answer is that I recently visited a local watering-hole with some
friends, and lined in the cramped ante-bar area were some video lottery
machines (no boon to those of us smooshed together, waiting in line to
get a drink).  My friend A. pointed to the screen of the nearest
one, which read

[Machine Configuration]      [Game Configuration]

…instead of the usual blinky-beepy come-ons.  Curious, we
pressed the reports button, and found the machine happy to give us
printouts of the game holds, results, revenues, etc.  For your
edification, I will be posting this information shortly.  However,
in sum, please be aware of the following:

– The EV on most all Oregon video lottery games is 0.90, or put another
way, the “hold” is 10%.  This is a truly outrageous rate that
makes casino roulette (~5.3%) blackjack (~1-2%) and craps (~1.5%) look
like great deals.

– The EV on “flush fever” is 0.94, or the hold is 6%.  This is
very bad, but a hell of a lot better than others (like “jacks or

– The “double up” game, offered after each win, is even-money (EV 1.00).

(Keep in mind that all games played against a “house” with
near-infinite resources subject the player to “gambler's ruin,” a
situation in which the player underperfoms his EV because short-term
variances wipe out his bankroll.  This boost the effective hold
over the theoretical hold, in most cases.)

Why is this significant?  After all, everyone knows that the
lottery is a sucker bet, right?  Well, perhaps, but there are
sucker bets, and then there are sucker bets.  You are wiped out
exponentially faster with such a huge edge as 10%.  Consider a
brisk but realistic pace of 360 video poker hands per hour — the least
that may be wagered is 25 cents.  The total action per hour is $90
— at 1% hold, the player loses less than a buck.  But with Oregon
video lottery, the least he will expect to lose is $9 per hour — more
than the state's minimum wage.  Consider, too, that the average
bet is larger, and that the swings of the game put him at risk of
gambler's ruin.

The difference between a sucker bet, and a sucker bet, is huge. 

III. My proposed scheme for remedying the situation.

Here is what should be done:

[As a general premise: 0. “Indian” casinos should be replaced with a
brand-new way to take land and manpower and make jobs; I call these
special programs Indian “factories.”  The Indian factories can
make “goods” that are exported at a “profit.”  This will give them
jobs and tribal tax revenues.]

[UPDATE: The Wall Street Journal recently covered a development where
it appears others share the above premise — there is now a trend for
Indian tribes to use reservation land to build legitimate industry,
like concrete plants.]

1. The state gives up video lottery.
2. To combat grey market video lottery, to prevent folks driving out of
state to play other states' terminals, and to ensure proper income
reporting for taxation, the state forms a video lottery audit board.
3. The audit board licenses establishments to have a certain number of
machines present, and licenses machine owners to run any number of
privately-owned machines with publicly-audited software.  Each
machine's hold percentage may be set and changed by its owner.
4. Each machine must be conspicuously labelled with its hold percentage / EV (see II. above) and most recent audit.
5. The audit board charges fees sufficient to fill its budget. 
Overage is rebated to license-holders, preventing the state from having
an interest in promoting video lottery.
6. Machine-owner licensees contract at arm's length, at-will, with
establishment-licensees as to machine placement.  This creates a
healthy, adversarial competition for the customer's dollar between the
booze and the slot machine.
7. The state makes its money off of income taxes.

The ends my plan serves are:
1. Elimination of state dependence upon, promotion of, or interest in, people losing more money at the video lottery.
2. Reduction in the “hold” and profitability of video machines by market forces, thereby:
3. Reducing incentives for “Indian” casinos by taking pricing power away from them on video poker-type games.
4. Reducing incentives for poorly managed bars by lowering the amount of the received subsidy from the video lottery.
5. Maximizing  happiness by promoting more play per unit wager for
lovers of video lottery and eliminating video lottery from some bars
for whom the lowered margins do not justify keeping the games.

FIX: Evil MSN Search spyware behavior for DNS errors in MSIE

In Microsoft Internet Explorer >= 5, a DNS error (asking for a hostname that doesn't exist) causes IE to pull an evil stunt and feed the requested URL to http://search.msn.com/dnserror.aspx , where it is used to search MSN and logged for who knows what nefarious purpose.  Rather than being opt-in behavior, this is opt-out, and rather than making it clear with a choice in options like “Automatically search when a site is not found”, opting out is a matter of making this choice:

Tools:Internet Options:Advanced:Search from the Address bar:Do not search from the Address bar.


CVSPermissions 0.3 patched to fix grep bug

CVSPermissions is a set of scripts that are called by CVS upon invoking
certain operations, such as commit (wisely, CVS has hooks for just this
purpose).  The scripts check an access control list, and
selectively permit operations based on username.  Unfortunately,
while the scripts come pretty elegantly close to “the simplest thing
that could possibly work,” they use grep without considering its
propensity for matching substrings within a string, so user “lou” will
match the ACL entry for “alouicious.”  The solution is adding ^
and $ around the grep regexes, which I have done in the attached

I haven't heard back from Vivek Venugopalan, the author of
CVSPermissions, about the bug.  So, I am providing CVSPermissions
v 0.3-rlucas-1 with my patches.  GNU GPL applies and AS-IS; I have
tested only on GNU/Linux with CVS 1.12.9 and GNU grep 2.5.1.


Happily, this is an open source success story.  Boy meets slightly
broken but otherwise perfect software, boy fixes software, software
helps boy do work, boy gives software back to the world.  It
brings tears to my eyes.

Update 2005-12-01: Vivek has emailed back and incorporated the changes; get the latest version at: http://www.sanchivi.com/cm/cvspermissions/

INFO: Apache SSL error: You have to perform a *full* server restart when you added or removed a certificate …

Have you seen this spuriously:

Ops, no RSA or DSA server certificate found?!
You have to perform a *full* server restart when you added or removed a certificate and/or key file

in your ssl error log (and of course your Apache didn't successfully start: ps -aux | grep httpd | wc -l is zero…) when you were using

apachectl restart

…or some utility that in turn used that method for restarting apache?  Try substituting

apachectl stop && apachectl start


BUG/WORKAROUND: Class::DBI / Postgres: "Can't delete: Can't bind a reference"

In Class::DBI, there appears to be a problem with the Postgresql driver
and certain kinds of relationships being defined.  It shows up as
a “can't bind a reference” error in the DBIx::Recordset code for

It persists for me with Class::DBI 0.96 and DBIx::Recordset 0.26.

The effect is seen for me when I retrieve a Class::DBI object id # 56
with some has_a relationships defined, and then try immediately 
to delete it.  It bombs out with

Can't delete 56: Can't bind a reference at blah/blah/blah/DBIx:/Recordset blah blah

I can work around this by 1. removing the has_a relationships, or 2.
stringifying the object before deleting it (found this inadvertantly in
writing some debug statements to explore this; very vexing that reading
a property has such a nonorthogonal effect, but I'll hush since I
haven't the time to become a CDBI developer myself).

INFO: Hawing PS12U Printserver CUPS URI for Linux printing

I have a Hawking Printserver, model number PS12U.  I had already set its IP address using the Windows software (it should be noted that you can ARP the printserver from Linux if need be; google for more info).  However, in order to set it up as a printer on my Linux machine, I needed the appropriate URI to feed to lpadmin.  I tried a number of things like ipp://, etc., but finally gave up and used “printconf.”  The proper URI / URL to use, it appears, for addressing the Hawking PS12U is:




Where the IP address in the middle is naturally the one you've set for the Printserver and the “lp1” to “lp3” corresponds to the physical port on the PS12U to which you've connected the printer.

I didn't say it was groundbreaking or an awesome fix, just info that I hadn't been able easily to find.

Migrating to new rlucas.net domain for most blogging

Gentle reader,

This server has gotten so slow,
probably thanks to Philip's blog, that
I have finally decided to put up my own server elsewhere.  Other
reasons are:

  • I can't use vim here to edit my entries.
  • I hate the HTML munging that this blog software uses.
  • Despite
    the PageRank boost of the .harvard.edu domain, I have decided to opt
    for the branding aspect of my long-time username, rlucas, which has
    been the local part of my Internet email address since 1993 or

And so, I am putting on hold this, my
Berkman blog.  I do intend to keep using it for Harvard-specific
things, on occasion, but my technical notes and, newly, my startup and
VC related dispatches, will be found from now on at my rlucas.net blog.

[FIX] Perl DBI / DBD::Pg bind values rely on Perl's automatic numeric/string scalar conversion

Scenario: you are using DBD::Pg to interface with your database (perhaps directly through DBI, or through an abstraction layer like Class::DBI or DBIx::ContextualFetch) when you get an odd result:

DBD::Pg::st execute failed: ERROR: parser: parse error at or near [your string, or the part of your string that doesn't begin with leading digits] at …


DBD::Pg::db selectrow_array failed: ERROR: Attribute “yourstring” not found at …

If you look at the PostgreSQL query log, you'll see that “yourstring” was not properly quoted as a literal in the SQL delivered to the parser.

Since you've either been relying upon your abstraction layer or personally doing the Right Thing and binding your values with the “WHERE thing=? AND otherthing=?” syntax, you're quite confused — this should all be quoted.

The problem is that Perl has flagged that scalar as a numeric value, possibly because you used a numeric operator on it (like > or == instead of gt or eq). The solution is to upgrade to DBD::Pg 1.32 or to explicitly stringify your string as “$yourstring”.

Below is the bug filed with CPAN.

Mac OS X 10.2, Perl 5.6.0, DBD::Pg 1.22, DBI 1.45

Bind values appear to rely upon Perl's automatic numeric/string scalar conversion in order to determine whether or not to quote.

This bug was discussed on

my $dbh = DBI->connect(…); #connect to Postgres; no errors with SQLite
my $scalar = “abc”;
warn “scalar is greater than zero (and now considered numeric)” if $scalar > 0;
warn “dbh->quote(scalar) works ok: ” . $dbh->quote($scalar);
warn “but bind values do not:” . $dbh->selectrow_array(

Using a numeric operator on the scalar makes Perl auto-convert it to a number; this is interpreted by the magic in Pg.xs as rendering the scalar ineligible for quoting.

One solution is to bind those variables that must be text but might have been numberified with “$varname”, thereby stringifying them in the eyes of Perl.