[postgis-users] shp2pgsql sequence and pkey
strk
strk at freek.keybit.net
Sat Aug 16 02:12:43 PDT 2003
Ok, I understand your and jeff's arguments, so here is the small patch
I've used to make current behaviour work with pgres<73.
------8<------------------------------------------------------------------
--- shp2pgsql.c.000 Wed Aug 13 11:02:57 2003
+++ shp2pgsql.c Wed Aug 13 11:10:19 2003
@@ -1451,5 +1451,9 @@
printf("\nALTER TABLE ONLY %s ADD CONSTRAINT %s_pkey PRIMARY KEY (gid);\n",table,table);
if(j > 1){
+#if USEVERSION > 72
printf("SELECT pg_catalog.setval ('%s_gid_seq', %i, true);\n",table, j-1);
+#else
+ printf("SELECT setval ('%s_gid_seq', %i, true);\n",table, j-1);
+#endif
}
}
--- Makefile.000 Wed Aug 13 11:09:37 2003
+++ Makefile Wed Aug 13 11:08:07 2003
@@ -24,6 +24,21 @@
OBJS = shpopen.o dbfopen.o getopt.o
+#---------------------------------------------------------------
+# Test the version string and set the USE_VERSION macro
+# appropriately.
+#
+ifneq ($(findstring 7.1,$(VERSION)),)
+ USE_VERSION=71
+else
+ ifneq ($(findstring 7.2,$(VERSION)),)
+ USE_VERSION=72
+ else
+ USE_VERSION=73
+ endif
+endif
+#---------------------------------------------------------------
-override CPPFLAGS := -I$(srcdir) -I$(top_builddir)/src/interfaces/libpq $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
+
+override CPPFLAGS := -I$(srcdir) -I$(top_builddir)/src/interfaces/libpq $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"' -DUSE_VERSION=$(USE_VERSION)
all: shp2pgsql$(EXE) pgsql2shp$(EXE)
------8<------------------------------------------------------------------
--strk;
pramsey wrote:
>
> > strk wrote:
>
> >>Finally my opinion about sequences and primary key: they should be
> >>optional. I'm ok with previous layout, I don't like to have the db
> >>full of sequences and indexes. I think the import step should be
> >>essential, indexes and constraints should be added by the DBA based
> >>on application specifications (why not a GiST index then ?).
>
> I would say they should be the default, but perhaps the user should have
> the option of turning them off. Using a pkey and sequence is a "best
> practice" and I would like to have the loader do that automagically for
> new inexperienced users. If an advanced DBA wants to roll her own stuff,
> then she can replace the pkeys and sequences after load, no?
>
> --
> __
> /
> | Paul Ramsey
> | Refractions Research
> | Email: pramsey at refractions.net
> | Phone: (250) 885-0632
> \_
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list