[postgis-users] create tables smarter

Frank Warmerdam warmerdam at pobox.com
Wed Jun 4 08:34:36 PDT 2008


Lee Hachadoorian wrote:
> Andreas,
> 
> AddGeometryColumn does two things: it adds a column of type geometry,
> and it adds a row to table geometry_columns.  If I understand what it
> is you want to do, you can do the SELECT and then add the row to
> geometry_columns with an INSERT statement:

Folks,

I did a presentation at PGCon and the issue of AddGeometryColumn() being
necessary to populate the geometry_columns table came up.  Some of the
postgres techies suggested there has been work so that extension defined
types could actually take extra arguments when used in the CREATE TABLE
statement and that this might let us avoid the need to use AddGeometryColumn().

ie.

CREATE TABLE ROADS
   (id   INT,
    name VARCHAR(255),
    geom GEOMETRY(<dimension>,<srid>,<type>) )

Then the callback for the GEOMETRY type would take care of extending the
geometry_columns table, presumably picking up the schema, table and column
name from the context.

In an ideal world, the dimension, srid and type would even show up when
you describe the table, and would be automatically propagated to new tables
created from a select.

I don't know how hard this is, or if I overestimated how these custom type
definition parsers work but I think it would be an appealing direction of
development for postgis.

Forgive me if I'm stating something already well understand in the postgis
community.  I'm a bit of a diletante in this world. :-)

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the postgis-users mailing list