Opened 7 years ago

Closed 7 years ago

#5547 closed enhancement (fixed)

PG: implement differed table creation

Reported by: Even Rouault Owned by: pg
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords: rouault
Cc: strk

Description

Currently, we do :

CREATE TABLE with the fid column SELECT AddGeometryColumn?(...) ALTER TABLE xxxx ADD COLUMN yyyy

With PostGIS 2.0, this can be conbined in a single CREATE TABLE statement. Furthermore, this will help with DDL triggers such as CartoDB ones when forcing the geometry column name to be the_geom as in CartoDB.

Change History (7)

comment:1 Changed 7 years ago by strk

I would note that non-geometrical fields can be all put in the initial CREATE TABLE also with older PostGIS versions. Even the geometrical ones can, except in pre-2.0 doing so would require an additional later step to "register" the field in the geometry_columns table and add the constraints.

comment:2 in reply to:  1 Changed 7 years ago by Even Rouault

Replying to strk:

I would note that non-geometrical fields can be all put in the initial CREATE TABLE also with older PostGIS versions. Even the geometrical ones can, except in pre-2.0 doing so would require an additional later step to "register" the field in the geometry_columns table and add the constraints.

True, but I don't think it is necessary to make specifi effort to optimize the PostGIS 1.X case. The following commit will put all regular field creation in CREATE TABLE for PostGIS 1.X, and all regular and geometry field creation for PostGIS 2.X.

trunk r27476 "PG: implement differed creation of tables to capture all attribute and geometry column creations into a single CREATE TABLE statement. Previous behaviour can be still used with defining the OGR_PG_DIFFERED_CREATION configuration option to NO (#5547)"

comment:3 Changed 7 years ago by strk

Uhm, is it a typo in the commit log to say that _previous_ behavior can be obtained setting OGR_PG_DIFFERED_CREATION=NO ?

I mean, doing full fields creation at CREATE TABLE is _not_ differed, right ?

comment:4 Changed 7 years ago by Even Rouault

No, there's no typo. Not sure to understand your question. Perhaps an ambiguity on what I mean by differed creation ? The new behaviour is differed creation since when you call CreateLayer?() or CreateField?() nothing appends, until you do a CreateFeature?() for example.

OGR_PG_DIFFERED_CREATION=NO should lead to same behaviour as before r27275. This is just a provision in case the new behaviour would cause some problems (I don't think it will, but who knows...)

comment:5 Changed 7 years ago by strk

Got it, thanks for the explanation.

comment:6 Changed 7 years ago by strk

I've tested the changes and they work fine for me, good work!

comment:7 Changed 7 years ago by Even Rouault

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.