Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
700 stars 145 forks source link

CHAR(31) literal leads to signal 11: Segmentation fault #61

Closed johnmudd closed 10 years ago

johnmudd commented 10 years ago

I was was trying to compare a literal to a VARCHAR(31) field in my table. I wasn't getting a match so I tried switching data types. When I tried the Equal operator and CHAR(31) type I get a signal 11: Segmentation fault. This is not a serious problem for me, just something I noticed.

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst'" | psql rx30
 patkey | namefirst | namelast |         adrsadd1         | adrscity | adrsstate | adrszip 
--------+-----------+----------+--------------------------+----------+-----------+---------
  36505 | First     | Lst      | 123 Xxxxxxxxxxxxx AVENUE | Xxxxx    | NJ        | 12345
(1 row)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 = '123 Xxxxxxxxxxxxx AVE         '" | psql rx30
 patkey | namefirst | namelast | adrsadd1 | adrscity | adrsstate | adrszip 
--------+-----------+----------+----------+----------+-----------+---------
(0 rows)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 = '123 Xxxxxxxxxxxxx AVE         '::VARCHAR(31)" | psql rx30
 patkey | namefirst | namelast | adrsadd1 | adrscity | adrsstate | adrszip 
--------+-----------+----------+----------+----------+-----------+---------
(0 rows)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 = '123 Xxxxxxxxxxxxx AVE          '::VARCHAR(31)" | psql rx30
 patkey | namefirst | namelast | adrsadd1 | adrscity | adrsstate | adrszip 
--------+-----------+----------+----------+----------+-----------+---------
(0 rows)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 = '123 Xxxxxxxxxxxxx AVE'::VARCHAR(31)" | psql rx30
 patkey | namefirst | namelast | adrsadd1 | adrscity | adrsstate | adrszip 
--------+-----------+----------+----------+----------+-----------+---------
(0 rows)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 = '123 Xxxxxxxxxxxxx AVE'::CHAR(31)" | psql rx30
connection to server was lost
$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 like '123 Xxxxxxxxxxxxx AVE'::CHAR(31)" | psql rx30
 patkey | namefirst | namelast | adrsadd1 | adrscity | adrsstate | adrszip 
--------+-----------+----------+----------+----------+-----------+---------
(0 rows)

$ echo "select patkey, namefirst, namelast, adrsadd1, adrscity, adrsstate, adrszip from patient where namefirst = 'First' and namelast = 'Lst' and adrsadd1 like '123 Xxxxxxxxxxxxx AVE%'::CHAR(31)" | psql rx30
 patkey | namefirst | namelast |         adrsadd1         | adrscity | adrsstate | adrszip 
--------+-----------+----------+--------------------------+----------+-----------+---------
  36505 | First     | Lst      | 123 Xxxxxxxxxxxxx AVENUE | Xxxxx    | NJ        | 12345
(1 row)

$ 
rdunklau commented 10 years ago

I can't reproduce the issue with a simple foreign table (using multicorn.testfdw.TestForeignDataWrapper) containing a char(31) column.

What postgresql, python and Multicorn version are you using ?

Would you happen to have a more precise test ?

johnmudd commented 10 years ago

FWIW, the column in the foreign table is VARCHAR(31).

    Namelast            VARCHAR(31),

Postgresql 9.3.1 compiled from source with --enable-cassert=no Python 2.7.6 Multicorn: git clone from Jan 3.

I can try to create a simpler test.

rdunklau commented 10 years ago

It is the same bug as #55, which has been corrected since.

For your information, there is now a "stable" 1.0.1 release both on pgxn, and as a tag here.

johnmudd commented 10 years ago

Thanks, I installed the latest code and it works.