Opened 8 years ago

Closed 8 years ago

#3451 closed defect (fixed)

Schema-qualify table names to avoid search path confusion or "column does not exist" error

Reported by: mst Owned by: robe
Priority: critical Milestone: PostGIS 2.2.3
Component: tiger geocoder Version: 2.2.x
Keywords: table name, column does not exist, schema Cc:

Description

At least some functions do not appear to schema-qualify table names and end up referencing the wrong table. This results in an error stating a column does not exist:

ERROR:  column co.statefp does not exist
LINE 2: ...cefp = p.placefp)  LEFT JOIN county co ON ('25' = co.statefp...
                                                             ^
CONTEXT:  PL/pgSQL function geocode_address(norm_addy,integer,geometry) line 383 at FOR over EXECUTE statement
PL/pgSQL function geocode(norm_addy,integer,geometry) line 14 at FOR over SELECT rows
PL/pgSQL function geocode(character varying,integer,geometry) line 26 at RETURN QUERY

In this case, the county table existed in another schema in the search path. Other table names used in the tiger and tiger_data schemas may also be in use (such as state, place, addr, zip_lookup, zip_state, etc. as well as their state-prefixed counterparts ma_place, id_addr, etc.). Schema-qualifying all table names should avoid this issue.

Attachments (1)

geocode_error_column_does_not_exist.txt (4.2 KB ) - added by mst 8 years ago.
Full PostgreSQL error output (attemped formatting for legibility)

Download all attachments as: .zip

Change History (8)

by mst, 8 years ago

Full PostgreSQL error output (attemped formatting for legibility)

comment:1 by mst, 8 years ago

Some addresses may not get located, returning the error. Original assumption that this was only a problem with unlocatable addresses appeared not to be the case. Renaming the other county table in the database allowed more locations and null values to be correctly returned.

comment:2 by robe, 8 years ago

(In [14778]) start schema qualifying calls references #3451

for PostGIS 2.3 trunk (will backport to 2.2 after testing)

Last edited 8 years ago by robe (previous) (diff)

comment:3 by robe, 8 years ago

Priority: mediumcritical

comment:4 by pramsey, 8 years ago

Milestone: PostGIS 2.2.2PostGIS 2.2.3

comment:5 by robe, 8 years ago

(In [14848]) Minor cleanup, change to schema qualify tables, change to use tiger node ids overlap instead of intersects for determining intersections Closes #3530 for PostGIS 2.2.3 References #3451

comment:6 by robe, 8 years ago

(In [14849]) Schema qualify calls and prevent error when tiger street number is not a number (just return first number part) References #3531 #3451 for PostGIS 2.2.3

comment:7 by robe, 8 years ago

Resolution: fixed
Status: newclosed

I think I took care of most of these at least important ones.

Note: See TracTickets for help on using tickets.