[TinyOWS-dev] pg_get_serial_sequence VS column_default for Pkey
Serge Dikiy
serge at gisfiber.com
Fri Feb 17 09:05:20 EST 2012
Hi,
What do you think the change "pg_get_serial_sequence" ->
"column_default" for Pkey?
Like this:
================================
diff -r 42ee60f4c797 ows/ows_psql.c
--- a/ows/ows_psql.c Fri Feb 17 14:03:53 2012 +0200
+++ b/ows/ows_psql.c Fri Feb 17 15:16:00 2012 +0200
@@ -423,9 +423,9 @@
*/
if (ln->layer->storage->pkey_sequence) {
sql_id = buffer_init();
- buffer_add_str(sql_id, "SELECT nextval('");
+ buffer_add_str(sql_id, "SELECT ");
buffer_copy(sql_id, ln->layer->storage->pkey_sequence);
- buffer_add_str(sql_id, "');");
+ buffer_add_str(sql_id, ";");
res = ows_psql_exec(o, sql_id->buf);
buffer_free(sql_id);
diff -r 42ee60f4c797 ows/ows_storage.c
--- a/ows/ows_storage.c Fri Feb 17 14:03:53 2012 +0200
+++ b/ows/ows_storage.c Fri Feb 17 15:16:00 2012 +0200
@@ -234,14 +234,14 @@
buffer_empty(sql);
PQclear(res);
- /* Now try to find a sequence related to this Pkey */
- buffer_add_str(sql, "SELECT pg_get_serial_sequence('");
+ /* Now try to find a DEFAULT value related to this Pkey */
+ buffer_add_str(sql, "SELECT column_default FROM
information_schema.columns WHERE table_schema = '");
buffer_copy(sql, l->storage->schema);
- buffer_add_str(sql, ".\"");
+ buffer_add_str(sql, "' AND table_name = '");
buffer_copy(sql, l->storage->table);
- buffer_add_str(sql, "\"', '");
+ buffer_add_str(sql, "' AND column_name = '");
buffer_copy(sql, l->storage->pkey);
- buffer_add_str(sql, "');");
+ buffer_add_str(sql, "';");
res = ows_psql_exec(o, sql->buf);
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
================================
Regards,
Serge Dikiy
More information about the TinyOWS-dev
mailing list