670 PGresult *result, *geocol_result;
671 GtkTreeIter iter, geocol_iter;
672 GtkListStore *dumper_geocol_combo_list;
673 char *connection_string, *sql_form, *query, *schema, *table, *geocol_query, *geocol_name=NULL;
683 query =
"SELECT tableoids.oid, n.nspname, tableoids.relname, COALESCE((SELECT 1 from pg_attribute WHERE attrelid = tableoids.oid AND atttypid IN (SELECT oid FROM pg_type WHERE typname in ('geometry', 'geography')) LIMIT 1), 0) hasgeo FROM (SELECT c.oid, c.relname, c.relnamespace FROM pg_class c WHERE c.relkind IN ('r', 'v', 'm', 'f','p') AND c.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname NOT ILIKE 'pg_%' AND nspname <> 'information_schema')) tableoids, pg_namespace n WHERE tableoids.relnamespace = n.oid ORDER BY n.nspname, tableoids.relname";
691 for (i = 0; i < PQntuples(result); i++)
698 schema = PQgetvalue(result, i, PQfnumber(result,
"nspname"));
699 table = PQgetvalue(result, i, PQfnumber(result,
"relname"));
701 sql_form =
"SELECT n.nspname, c.relname, a.attname FROM pg_class c, pg_namespace n, pg_attribute a WHERE c.relnamespace = n.oid AND n.nspname = '%s' AND c.relname = '%s' AND a.attrelid = c.oid AND a.atttypid IN (SELECT oid FROM pg_type WHERE typname in ('geometry', 'geography'))";
703 geocol_query =
malloc(strlen(sql_form) + strlen(schema) + strlen(table) + 1);
704 sprintf(geocol_query, sql_form, schema, table);
714 if (PQntuples(geocol_result) > 0)
717 for (j = 0; j < PQntuples(geocol_result); j++)
719 geocol_name = PQgetvalue(geocol_result, j, PQfnumber(geocol_result,
"attname"));
722 gtk_list_store_set(dumper_geocol_combo_list, &geocol_iter,
733 gtk_list_store_set(dumper_geocol_combo_list, &geocol_iter,
739 PQclear(geocol_result);
745 hasgeo = atoi(PQgetvalue(result, i, PQfnumber(result,
"hasgeo")));
static SHPCONNECTIONCONFIG * conn
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
static PGconn * pg_connection
GtkListStore * chooser_table_list_store