psql/perl oddity
Madison Kelly
linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Wed Aug 18 20:28:43 UTC 2004
Hi all,
I hope this doesn't turn out to be ab obvious question but at the
moment I am stumped...
I am trying to read in some values from a database. If I manually
enter the SELECT statement all the values come back properly. If I try
to get perl to read them though I can't get the value out of one column
but the rest are fine...
Here is what is in the relevant DB table:
mntdir | freecap | maxcap | usedcap |
assign_up_to | assigned_space | fs
------------------+-------------+-------------+-------------+--------------+----------------+------
| 19947421696 | 22094331904 | 1024573440 |
0 | 0 | ext3
| 1781760000 | 1912516608 | 33603584 |
0 | 0 | ext3
| 1593700352 | 1714405376 | 33615872 |
0 | 0 | ext3
| 2092072960 | 2285854720 | 77664256 |
0 | 0 | ext3
/ | 2513367040 | 24514211840 | 20755587072 |
0 | 0 | ext3
/mnt/tle-bu/src0 | 232838144 | 259932160 | 13669376 |
0 | 0 | ext3
/mnt/tle-bu/src1 | 185249792 | 4227399680 | 3827400704 |
0 | 0 | ext3
/mnt/tle-bu/dst2 | 13286752256 | 22435807232 | 9149054976 |
786598555 | 0 | vfat
| 57528414208 | 78766505984 | 17236905984 |
0 | 0 | ext3
| 35888373760 | 39387484160 | 1498312704 |
0 | 0 | ext3
/mnt/tle-bu/dst1 | 23020912640 | 24288321536 | 33619968 |
786598556 | 0 | ext3
/mnt/tle-bu/dst0 | 30556512256 | 32384032768 | 182468608 |
786598555 | 0 | ext3
Notice that 'assigned_space' is '0' but 'assign_up_to' has a value on
three entries (786598555)? If I try to read this out with this statement:
SELECT mntdir, freecap, maxcap, usedcap, assign_up_to, assigned_space,
fs FROM dev WHERE uuid='78A3-2578';
I get:
mntdir | freecap | maxcap | usedcap |
assign_up_to | assigned_space | fs
------------------+-------------+-------------+------------+--------------+----------------+------
/mnt/tle-bu/dst2 | 13286752256 | 22435807232 | 9149054976 |
786598555 | 0 | vfat
Perfect! Notice that 'assign_up_to' has a value? Well, when I try to
do the same thing in perl like this it is always returns '0':
print " |- DBI: SELECT mntdir, freecap, maxcap, usedcap, assign_up_to,
assigned_space, fs FROM dev WHERE uuid='$uuid';\n";
$DBreq=$DB->prepare("SELECT mntdir, freecap, maxcap, usedcap,
assign_up_to, assigned_space, fs FROM dev WHERE uuid='$uuid'") || die
$DBI::errstr;
$null=$DBreq->execute();
@part_info=$DBreq->fetchrow_array();
print " | |- DEBUG: mntdir: [$part_info[0]], freecap: [$part_info[1]],
maxcap: [$part_info[2]], usedcap: [$part_info[3]], assign_up_to:
[$part_info[4]], assigned_space: [$part_info[5]], fs: [$part_info[6]]\n";
This prints this output:
mntdir: [/mnt/tle-bu/dst2], freecap: [13286752256], maxcap:
[22435807232], usedcap: [9149054976], assign_up_to: [0], assigned_space:
[0], fs: [vfat]
It doesn't matter what order I call the columns in, it is always that
one column that returns '0'. The column is 'BIGINT', Not Null, Default
0, in case it matters.
Can anyone see what I am doing wrong? Thanks!
Madison
PS - I make a LOT of DB calls in this program and so far as I can tell
this is the only place that it glitches.
PPS - Here's what PostgreSQL makes of this table:
Table "public.dev"
Column | Type | Modifiers
------------------+------------------------+------------------------
uuid | character varying(40) | not null
path | character varying(255) |
label | character varying(255) |
sec_type | character varying(32) |
type | character varying(32) |
fs | character varying(32) |
mntdir | character varying(255) |
premount | integer | not null default 0
mntstat | integer | not null default 0
maxcap | bigint |
maxcap_com | character varying(128) |
maxcap_hr | real |
maxcap_pf | character varying(8) |
usedcap | bigint |
usedcap_com | character varying(128) |
usedcap_hr | real |
usedcap_pf | character varying(8) |
freecap | bigint |
freecap_com | character varying(128) |
freecap_hr | real |
freecap_pf | character varying(8) |
usedprc | integer |
usedprc_barused | integer |
usedprc_barfree | integer |
bar_colour | character varying(8) |
assigned | integer | not null default 0
last_update_date | character varying(12) |
last_update_time | character varying(20) |
online | boolean |
comment | text |
in_use_by | integer | not null default 0
in_use_set | integer | not null default 0
in_use_locked | boolean | not null default false
assign_up_to | bigint | not null default 0
assigned_space | bigint | not null default 0
Indexes:
"dev_pkey" primary key, btree (uuid)
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list