Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-24-2008, 06:12 PM
Javier Hernandez
 
Posts: n/a
Default BUG #4113: server closed the connection unexpectedly


The following bug has been logged online:

Bug reference: 4113
Logged by: Javier Hernandez
Email address: dba@loopone.com
PostgreSQL version: 8.3.1
Operating system: Linux version 2.6.9-11.ELsmp; Red Hat 3.4.3-22; gcc
version 3.4.3
Description: server closed the connection unexpectedly
Details:

The following script generates an unexpected loss of connection.


begin;

\echo "Creating a table to hold numeric values only"
create table numeric_col_table (
num_col numeric(6,0) primary key not null
);

\echo "Creating a table to hold integer values only"
create table int_col_table (
int_col integer primary key not null
);


\echo "Inserting data into our numeric-only table"
insert into numeric_col_table (num_col) values (1), (2), (3);

\echo "Inserting data into our integer-only table"
insert into int_col_table (int_col) values (1), (2), (3);

\echo "Show contents of the numeric table"
select * from numeric_col_table;

\echo "Show contents of the numeric table"
select * from int_col_table;

\echo "Select everything from the integer table where int_col =
numeric_col"
select * from int_col_table where int_col in (select num_col from
numeric_col_table);

\echo "Select everything from the numeric table where numeric_col =
int_col"
select * from numeric_col_table where num_col in (select int_col from
int_col_table);

rollback;

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-24-2008, 06:12 PM
Bruce Momjian
 
Posts: n/a
Default Re: BUG #4113: server closed the connectionunexpectedly


Ouch, crash confirmed --- studying the cause now.

---------------------------------------------------------------------------

Javier Hernandez wrote:
>
> The following bug has been logged online:
>
> Bug reference: 4113
> Logged by: Javier Hernandez
> Email address: dba@loopone.com
> PostgreSQL version: 8.3.1
> Operating system: Linux version 2.6.9-11.ELsmp; Red Hat 3.4.3-22; gcc
> version 3.4.3
> Description: server closed the connection unexpectedly
> Details:
>
> The following script generates an unexpected loss of connection.
>
>
> begin;
>
> \echo "Creating a table to hold numeric values only"
> create table numeric_col_table (
> num_col numeric(6,0) primary key not null
> );
>
> \echo "Creating a table to hold integer values only"
> create table int_col_table (
> int_col integer primary key not null
> );
>
>
> \echo "Inserting data into our numeric-only table"
> insert into numeric_col_table (num_col) values (1), (2), (3);
>
> \echo "Inserting data into our integer-only table"
> insert into int_col_table (int_col) values (1), (2), (3);
>
> \echo "Show contents of the numeric table"
> select * from numeric_col_table;
>
> \echo "Show contents of the numeric table"
> select * from int_col_table;
>
> \echo "Select everything from the integer table where int_col =
> numeric_col"
> select * from int_col_table where int_col in (select num_col from
> numeric_col_table);
>
> \echo "Select everything from the numeric table where numeric_col =
> int_col"
> select * from numeric_col_table where num_col in (select int_col from
> int_col_table);
>
> rollback;
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs


--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-24-2008, 06:12 PM
Alvaro Herrera
 
Posts: n/a
Default Re: BUG #4113: server closed the connection unexpectedly

Javier Hernandez wrote:

> select * from numeric_col_table where num_col in (select int_col from
> int_col_table);


#0 0x0000000000752368 in pg_detoast_datum (datum=0x1)
at /pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:2101
#1 0x00000000006bf8bc in hash_numeric (fcinfo=0x7fffc5140550)
at /pgsql/source/00head/src/backend/utils/adt/numeric.c:1163
#2 0x000000000075081f in FunctionCall1 (flinfo=0xc65688, arg1=1)
at /pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:1250
#3 0x00000000005898c1 in TupleHashTableHash (key=0x7fffc51409f0, keysize=8)
at /pgsql/source/00head/src/backend/executor/execGrouping.c:513
#4 0x00000000007550ee in hash_search (hashp=0xc6aec8, keyPtr=0x7fffc51409f0, action=HASH_ENTER,
foundPtr=0x7fffc51409ef "") at /pgsql/source/00head/src/backend/utils/hash/dynahash.c:791
#5 0x0000000000589635 in LookupTupleHashEntry (hashtable=0xc68eb8, slot=0xc63078,
isnew=0x7fffc5140a6f "") at /pgsql/source/00head/src/backend/executor/execGrouping.c:368
#6 0x000000000059e2e3 in lookup_hash_entry (aggstate=0xc64490, inputslot=0xc63138)
at /pgsql/source/00head/src/backend/executor/nodeAgg.c:777
#7 0x000000000059e701 in agg_fill_hash_table (aggstate=0xc64490)
at /pgsql/source/00head/src/backend/executor/nodeAgg.c:1028
#8 0x000000000059e35e in ExecAgg (node=0xc64490)
at /pgsql/source/00head/src/backend/executor/nodeAgg.c:812


So what's happening here is that it's writing the hash table using the
wrong datatype ...

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-24-2008, 06:12 PM
Tom Lane
 
Posts: n/a
Default Re: BUG #4113: server closed the connection unexpectedly

Alvaro Herrera <alvherre@commandprompt.com> writes:
> Javier Hernandez wrote:
>> select * from numeric_col_table where num_col in (select int_col from
>> int_col_table);


> So what's happening here is that it's writing the hash table using the
> wrong datatype ...


Yeah, the planner is at fault here --- it should be coercing the value
to numeric before hashing. I think this is wrong all the way back,
but pre-8.3 you'd have silently gotten wrong answers instead of a crash,
because the executor made up its own mind about how to unique-ify the
subquery outputs, and it looked directly at their actual data type
and chose some default equality operator for that. This can be
demonstrated to be the Wrong Thing when the conversion to the IN
operator's datatype is lossy, as in this variant example:

create table numeric_col_table (
num_col numeric
);

create table float_col_table (
float_col float8
);

insert into numeric_col_table values (1), (1.000000000000000000001), (2), (3);

insert into float_col_table values (1), (2), (3);

select * from numeric_col_table;

select * from float_col_table;

select * from float_col_table where float_col in (select num_col from
numeric_col_table);

In 8.2 I get bogus results like

float_col
-----------
1
1
2
3
(4 rows)

because 1 and 1.000000000000000000001 are perfectly distinct numeric
values, but not so much after they've been coerced to float.

In 8.3/HEAD I think this can be fixed by coercing the Vars that are put
into the InClauseInfo entry for the IN join. Not sure how far back it
will be practical to apply that fix, though.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-24-2008, 06:12 PM
Tom Lane
 
Posts: n/a
Default Re: BUG #4113: server closed the connection unexpectedly

"Javier Hernandez" <dba@loopone.com> writes:
> The following script generates an unexpected loss of connection.


I've applied a patch for this. Thanks for the report!

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:33 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145