]> granicus.if.org Git - postgis/commitdiff
Additional check with warnings if PostgreSQL identifiers exceed the standard maximum...
authorBborie Park <bkpark at ucdavis.edu>
Tue, 13 Dec 2011 01:58:50 +0000 (01:58 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 13 Dec 2011 01:58:50 +0000 (01:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8370 b70326c6-7e19-0410-871a-916f4a2858ee

raster/loader/raster2pgsql.c
raster/loader/raster2pgsql.h

index dfb7c013f12ad6a3e2bca24241ee104c02c29b8b..5bb20341ba279c7d756e3f0b411fd3ed0bd63a46 100644 (file)
@@ -2142,6 +2142,47 @@ main(int argc, char **argv) {
        * check that identifiers won't get truncated
        ****************************************************************************/
 
+       if (config->schema != NULL && strlen(config->schema) > MAXNAMELEN) {
+               fprintf(stderr, _("The schema name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                       config->schema,
+                       MAXNAMELEN
+               );
+       }
+       if (config->table != NULL && strlen(config->table) > MAXNAMELEN) {
+               fprintf(stderr, _("The table name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                       config->table,
+                       MAXNAMELEN
+               );
+       }
+       if (config->raster_column != NULL && strlen(config->raster_column) > MAXNAMELEN) {
+               fprintf(stderr, _("The column name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                       config->raster_column,
+                       MAXNAMELEN
+               );
+       }
+       if (config->tablespace != NULL && strlen(config->tablespace) > MAXNAMELEN) {
+               fprintf(stderr, _("The tablespace name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                       config->tablespace,
+                       MAXNAMELEN
+               );
+       }
+       if (config->idx_tablespace != NULL && strlen(config->idx_tablespace) > MAXNAMELEN) {
+               fprintf(stderr, _("The index tablespace name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                       config->idx_tablespace,
+                       MAXNAMELEN
+               );
+       }
+       if (config->overview_count) {
+               for (i = 0; i < config->overview_count; i++) {
+                       if (strlen(config->overview_table[i]) > MAXNAMELEN) {
+                               fprintf(stderr, _("The overview table name \"%s\" may exceed the maximum string length permitted for PostgreSQL identifiers (%d).\n"),
+                                       config->overview_table[i],
+                                       MAXNAMELEN
+                               );
+                       }
+               }
+       }
+
        /****************************************************************************
        * double quote identifiers
        ****************************************************************************/
index 8890c6c67480a71f3639a2183b4ae62769dd5b9c..4d449fb6aa467552c1163781f46e50bf973e9f74 100644 (file)
@@ -46,7 +46,8 @@
 #define CSEQUAL(a,b) (strcmp(a,b)==0)
 
 /*
-       max length of of "name" data type in PostgreSQL
+       max length of of "name" data type in PostgreSQL as
+       defined in pg_config_manual.h as macro NAMEDATALEN
        default is 64 bytes (63 usable characters plus NULL)
 */
 #define MAXNAMELEN 63