Re: [postgis-users] create tables smarter

2008-06-04 Thread Paul Ramsey
On Wed, Jun 4, 2008 at 6:35 PM, Stephen Frost > Just an fyi, the parameterized user-defined types was added in 8.3, so > we don't actually need to wait for 8.4. :) Look at me, asleep at the switch! :) P ___ postgis-users mailing list postgis-users@postgi

Re: [postgis-users] create tables smarter

2008-06-04 Thread Stephen Frost
* Chris Hermansen ([EMAIL PROTECTED]) wrote: > >> Paul Ramsey wrote: > >> > >>> Trust me, Chris, the maintenance of GEOMETRY_COLUMNS has been a > >>> longstanding bug'a'bear and in retrospect we probably would have been > >>> better off without it. In order to get an automagic GEOMETRY_COLUMN

Re: [postgis-users] create tables smarter

2008-06-04 Thread Chris Hermansen
Kevin, I'm always game to try something that's potentially worthwhile :-) clh=# create table tracks (tablename name); CREATE TABLE clh=# create rule table_rule as on insert to pg_class do also insert into tracks values (new.relname); CREATE RULE clh=# create table foo (a in

Re: [postgis-users] create tables smarter

2008-06-04 Thread Kevin Neufeld
Chris Hermansen wrote: ... OK, so far, so good. Let's try the same thing with pg_tables: clh=# drop rule table_rule on data; DROP RULE clh=# drop table tracks; DROP TABLE clh=# drop table data; DROP TABLE clh=# create table tracks (tablename name); CREATE TABLE

Re: [postgis-users] create tables smarter

2008-06-04 Thread Chris Hermansen
"try and see", those are words I like. But first I googled, and I saw past discussions of the futility of trying to create triggers on systems tables. However, nothing I saw indicated I couldn't create a rule on a systems table, so I decided to try it. First, I decided to do a straightforward ex

Re: [postgis-users] create tables smarter

2008-06-04 Thread Paul Ramsey
Triggers on system tables aren't allowed, try and see. I like that GEOMETRY_COLUMNS provides a visible and standard way for 3rd party apps to understand the geometry in the database, and I hate having to maintain it. I've been wanting to make it magical for many years. There's other ways to do it

Re: [postgis-users] create tables smarter

2008-06-04 Thread Chris Hermansen
Paul says "the maintenance of GEOMETRY_COLUMNS has been a longstanding bug'a'bear"... Why don't I find that surprising :-) But anyway, Paul also says that triggers on system tables could have been used. And I guess that makes me wonder, is there anything to stop a person from putting triggers on

Re: [postgis-users] create tables smarter

2008-06-04 Thread Paul Ramsey
Trust me, Chris, the maintenance of GEOMETRY_COLUMNS has been a longstanding bug'a'bear and in retrospect we probably would have been better off without it. In order to get an automagic GEOMETRY_COLUMNS though, we either required (a) triggers on system tables or (b) parameterized user-defined type

Re: [postgis-users] create tables smarter

2008-06-04 Thread Chris Hermansen
Hi Frank, folks; This is the kind of thing that would be really great to see: * a way of creating geometry that relied on SQL and not on calling stored procedures * a way of deleting same * a system table that held ancilliary information It bugs me that I can DROP a table and s

Re: [postgis-users] create tables smarter

2008-06-04 Thread Stephen Woodbridge
Kevin Neufeld wrote: Actually Lee, addgeometrycolumn does three things. Two, as you mentioned, and three, it adds constraints to your table so that all geometries in your column have the same srid and are of the same dimension and geometry type. The function Stephen mentioned does exist, but

Re: [postgis-users] create tables smarter

2008-06-04 Thread Lee Hachadoorian
Kevin, In that case I think Andreas could accomplish this using CREATE TABLE new_table ( LIKE old_table INCLUDING CONSTRAINTS ); followed by probe_geometry_columns( ). I tested this in my database on an arbitrarily selected spatial table and it seems to have worked. Lee Hachadoorian PhD Studen

Re: [postgis-users] create tables smarter

2008-06-04 Thread Kevin Neufeld
Actually Lee, addgeometrycolumn does three things. Two, as you mentioned, and three, it adds constraints to your table so that all geometries in your column have the same srid and are of the same dimension and geometry type. The function Stephen mentioned does exist, but it's called probe_ge

RE: [postgis-users] create tables smarter

2008-06-04 Thread Obe, Regina
Sent: Wednesday, June 04, 2008 10:29 AM To: PostGis_Mailinglist Subject: [postgis-users] create tables smarter Hello list, i am searching for a solution for creating tables with less typing. I do not want to type every column i want to have in my new table, especially if column names will not

Re: [postgis-users] create tables smarter

2008-06-04 Thread Paul Ramsey
On Wed, Jun 4, 2008 at 8:34 AM, Frank Warmerdam <[EMAIL PROTECTED]> wrote: > 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 >

Re: [postgis-users] create tables smarter

2008-06-04 Thread Markus Schaber
Hi, Frank, Frank Warmerdam <[EMAIL PROTECTED]> wrote: > 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. I would prefer changing geometry_columns into a VIEW. > I don't

Re: [postgis-users] create tables smarter

2008-06-04 Thread Frank Warmerdam
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

Re: [postgis-users] create tables smarter

2008-06-04 Thread Bruce Rindahl
Bruce Rindahl wrote: Chris Hermansen wrote: There was a discussion awhile ago on this list about the ability to do something like: CREATE TABLE foo AS SELECT * EXCEPT X,Y,Z FROM bar; I don't recall if someone had a real solution (other than extending PostgreSQL :-)) but you might troll the a

Re: [postgis-users] create tables smarter

2008-06-04 Thread Bruce Rindahl
Chris Hermansen wrote: There was a discussion awhile ago on this list about the ability to do something like: CREATE TABLE foo AS SELECT * EXCEPT X,Y,Z FROM bar; I don't recall if someone had a real solution (other than extending PostgreSQL :-)) but you might troll the archives a bit for 2007

Re: [postgis-users] create tables smarter

2008-06-04 Thread Lee Hachadoorian
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: INSERT INTO public.geometry_columns VALU

Re: [postgis-users] create tables smarter

2008-06-04 Thread Chris Hermansen
There was a discussion awhile ago on this list about the ability to do something like: CREATE TABLE foo AS SELECT * EXCEPT X,Y,Z FROM bar; I don't recall if someone had a real solution (other than extending PostgreSQL :-)) but you might troll the archives a bit for 2007. Andreas Laggner wrot

Re: [postgis-users] create tables smarter

2008-06-04 Thread Stephen Woodbridge
Andreas Laggner wrote: Hello list, i am searching for a solution for creating tables with less typing. I do not want to type every column i want to have in my new table, especially if column names will not change! I cannot use the postgresql "create table tablename as select * from" because of t

[postgis-users] create tables smarter

2008-06-04 Thread Andreas Laggner
Hello list, i am searching for a solution for creating tables with less typing. I do not want to type every column i want to have in my new table, especially if column names will not change! I cannot use the postgresql "create table tablename as select * from" because of the geometry column (with