[SCM] PostGIS branch master updated. 3.6.0rc2-645-g1c8bb486c

git at osgeo.org git at osgeo.org
Sun Jun 21 09:56:18 PDT 2026


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  1c8bb486ca51d64a9cc767c0a2a487c2275be33b (commit)
       via  c222d23c27f4225b403ac19bfe53cff2c557e1a0 (commit)
      from  45c26068ef27de003a39e69c01532340063ecc13 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1c8bb486ca51d64a9cc767c0a2a487c2275be33b
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Jun 21 18:34:09 2026 +0400

    Add long option aliases to shp2pgsql
    
    Accept GNU-style long aliases for existing shp2pgsql command-line options, including --option=value spelling for value-taking options. Reuse the existing short-option switch so the loader action long options remain the canonical action vocabulary.
    
    References #4658

diff --git a/NEWS b/NEWS
index 4fb4532c8..199261ee1 100644
--- a/NEWS
+++ b/NEWS
@@ -24,7 +24,7 @@ To take advantage of all postgis_sfcgal extension features SFCGAL 2.3+ is needed
  - #1124, #2935, #4658, #4659, [loader] Rework loader arguments: shp2pgsql can
           create UNLOGGED tables, shp2pgsql --drop-table can emit DROP TABLE
           before prepare output, raster2pgsql/shp2pgsql expose loader actions
-          as long options, raster2pgsql accepts long aliases for existing
+          as long options, both loaders accept long aliases for existing
           options, and --if-not-exists makes creation actions idempotent
           (Darafei Praliaskouski)
  - #4208, Add single-geometry variants of ST_MaxDistance and ST_LongestLine
diff --git a/doc/man/shp2pgsql.1 b/doc/man/shp2pgsql.1
index 2cd3b9720..2895b5c36 100644
--- a/doc/man/shp2pgsql.1
+++ b/doc/man/shp2pgsql.1
@@ -30,6 +30,8 @@ the geometry will be placed in the 'geo_value' column by default.
 .LP 
 The loader has several operating modes distinguished by command line flags:
 
+Long options that take values also accept the \fB\-\-option=value\fR spelling.
+
 (Note that \-a, \-c, \-d and \-p are mutually exclusive.)
 .TP 
 \fB\-d\fR
@@ -61,44 +63,41 @@ create-and-load action set.
 \fB\-\-load\-data\fR
 Load Shape file rows into the target table.
 .TP
-\fB\-D\fR
+\fB\-D\fR, \fB\-\-dump\-format\fR
 Use the PostgreSQL "dump" format for the output data. This can be combined 
 with \-a, \-c and \-d. It is much faster to load than the default "insert"
 SQL format. Use this for very large data sets.
 .TP 
-\fB\-w\fR
+\fB\-w\fR, \fB\-\-use\-wkt\fR
 Output WKT format, instead of WKB.  Note that this can
 introduce coordinate drifts due to loss of precision.
 .TP 
-\fB\-e\fR
+\fB\-e\fR, \fB\-\-no\-transaction\fR
 Execute each statement on its own, without using a transaction.
 This allows loading of the majority of good data when there are some bad
 geometries that generate errors.  Note that this cannot be used with the
 \-D flag as the "dump" format always uses a transaction.
 .TP
-\fB\-\-no\-transaction\fR
-Execute each statement individually, without using a transaction.
-.TP
-\fB\-s\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
+\fB\-s\fR, \fB\-\-srid\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
 Creates and populates the geometry tables with the specified SRID.
 If FROM_SRID is given, the geometries will be reprojected.
 Reprojection cannot be used with \-D.
 .TP 
-\fB\-G\fR
+\fB\-G\fR, \fB\-\-geography\fR
 Use the geography type instead of geometry.  Geography is used to store
 lat/lon data.  At the moment the only spatial reference supported is 4326.
 .TP 
-\fB\-g\fR <\fIgeometry_column\fR>
+\fB\-g\fR, \fB\-\-geometry\-column\fR <\fIgeometry_column\fR>
 Specify the name of the geometry column (mostly useful in append mode).
 .TP 
 \fB\-\-create\-index\fR
 Create a spatial index on the geometry column.
 .TP
-\fB\-k\fR
+\fB\-k\fR, \fB\-\-keep\-case\fR
 Keep identifiers case (column, schema and attributes). Note that attributes 
 in Shapefile are usually all UPPERCASE.
 .TP 
-\fB\-m\fR <\fIfilename\fR>
+\fB\-m\fR, \fB\-\-column\-map\fR <\fIfilename\fR>
 Specify a file containing a set of mappings of (long) column names to 10
 character DBF column names. The content of the file is one or more lines 
 of two names separated by white space and no trailing or leading space:
@@ -109,18 +108,21 @@ AVERYLONGCOLUMNNAME DBFFIELD2\\n
 
 etc.
 .TP 
-\fB\-i\fR
+\fB\-i\fR, \fB\-\-force\-int4\fR
 Coerce all integers to standard 32\-bit integers, do not create 64\-bit 
 bigints, even if the DBF header signature appears to warrant it.
 .TP 
-\fB\-S\fR
+\fB\-S\fR, \fB\-\-simple\-geometries\fR
 Generate simple Geometries instead of MULTIgeometries. Shape files don't 
 differ between LINESTRINGs and MULTILINESTRINGs, so shp2pgsql generates 
 MULTILINESTRINGs by default. This switch will produce LINESTRINGs instead, 
 but shp2pgsql will fail when it hits a real MULTILINESTRING. The same works
 for POLYGONs vs. MULTIPOLYGONs.
 .TP 
-\fB\-W\fR <\fIencoding\fR>
+\fB\-t\fR, \fB\-\-dimensionality\fR <\fIdimensionality\fR>
+Force geometry to be one of 2D, 3DZ, 3DM, or 4D.
+.TP
+\fB\-W\fR, \fB\-\-encoding\fR <\fIencoding\fR>
 Specify the character \fIencoding\fR of Shapefile's attributes.
 If this option is used the output will be encoded in UTF-8.
 .TP 
@@ -136,24 +138,27 @@ Analyze the table after loading.
 \fB\-\-no\-analyze\fR
 Prevent tables from being analyzed.
 .TP
-\fB\-u\fR
+\fB\-u\fR, \fB\-\-unlogged\fR
 Create the target table as UNLOGGED. This can speed up loading transient
 staging data, but PostgreSQL does not preserve unlogged table contents after
 a crash or unclean shutdown.
 .TP
-\fB\-N\fR <\fIpolicy\fR>
+\fB\-N\fR, \fB\-\-null\-policy\fR <\fIpolicy\fR>
 Specify NULL geometries handling policy (insert,skip,abort).
+.TP
+\fB\-n\fR, \fB\-\-dbf\-only\fR
+Only import the DBF file.
 .TP 
-\fB\-T\fR <\fItablespace\fR>
+\fB\-T\fR, \fB\-\-tablespace\fR <\fItablespace\fR>
 Specify the tablespace for the new table.  Indexes will still use the
 default tablespace unless the \-X parameter is also used.  The PostgreSQL
 documentation has a good description on when to use custom tablespaces.
 .TP 
-\fB\-X\fR <\fItablespace\fR>
+\fB\-X\fR, \fB\-\-index\-tablespace\fR <\fItablespace\fR>
 Specify the tablespace for the new table's indexes.  This applies to
 the primary key index, and the GIST spatial index if \-I is also used.
 .TP 
-\fB\-?\fR
+\fB\-?\fR, \fB\-\-help\fR
 Display version and usage information.
 
 .SH "INSTALLATION"
diff --git a/loader/shp2pgsql-cli.c b/loader/shp2pgsql-cli.c
index bcd03e516..13690e91f 100644
--- a/loader/shp2pgsql-cli.c
+++ b/loader/shp2pgsql-cli.c
@@ -20,16 +20,100 @@
 #define xstr(s) str(s)
 #define str(s) #s
 
+typedef struct {
+	const char *name;
+	int short_option;
+	int takes_value;
+} ShpLoaderLongOption;
+
+static const ShpLoaderLongOption long_option_aliases[] = {
+    {"column-map", 'm', 1},
+    {"create-index", 'I', 0},
+    {"dbf-only", 'n', 0},
+    {"dimensionality", 't', 1},
+    {"dump-format", 'D', 0},
+    {"encoding", 'W', 1},
+    {"force-int4", 'i', 0},
+    {"geography", 'G', 0},
+    {"geometry-column", 'g', 1},
+    {"help", '?', 0},
+    {"index-tablespace", 'X', 1},
+    {"keep-case", 'k', 0},
+    {"no-analyze", 'Z', 0},
+    {"no-transaction", 'e', 0},
+    {"null-policy", 'N', 1},
+    {"simple-geometries", 'S', 0},
+    {"srid", 's', 1},
+    {"tablespace", 'T', 1},
+    {"unlogged", 'u', 0},
+    {"use-wkt", 'w', 0},
+};
+
+static int
+consume_long_option(int argc, char **argv, int *option)
+{
+	char *arg = argv[pgis_optind];
+	char *equals = strchr(arg, '=');
+	size_t name_len = equals ? (size_t)(equals - arg - 2) : strlen(arg + 2);
+	size_t i;
+
+	if (strncmp(arg, "--", 2) != 0)
+		return 0;
+
+	for (i = 0; i < sizeof(long_option_aliases) / sizeof(long_option_aliases[0]); i++)
+	{
+		const ShpLoaderLongOption *alias = &long_option_aliases[i];
+		if (strlen(alias->name) != name_len || strncmp(arg + 2, alias->name, name_len) != 0)
+			continue;
+
+		if (alias->takes_value)
+		{
+			if (equals)
+			{
+				pgis_optarg = equals + 1;
+				pgis_optind++;
+			}
+			else if (pgis_optind + 1 < argc)
+			{
+				pgis_optarg = argv[pgis_optind + 1];
+				pgis_optind += 2;
+			}
+			else
+			{
+				fprintf(stderr, "Option requires an argument: --%s\n", alias->name);
+				exit(1);
+			}
+		}
+		else
+		{
+			if (equals)
+			{
+				fprintf(stderr, "Option does not take an argument: --%s\n", alias->name);
+				exit(1);
+			}
+			pgis_optarg = NULL;
+			pgis_optind++;
+		}
+
+		*option = alias->short_option;
+		return 1;
+	}
+
+	return 0;
+}
+
 static void
 usage()
 {
 	printf(_( "RELEASE: %s (%s)\n" ),
 		POSTGIS_LIB_VERSION, xstr(POSTGIS_REVISION));
-	printf(_( "USAGE: shp2pgsql [<options>] <shapefile> [[<schema>.]<table>]\n"
-	          "OPTIONS:\n" ));
-	printf(_( "  -s [<from>:]<srid> Set the SRID field. Defaults to %d.\n"
-	          "      Optionally reprojects from given SRID.\n"),
-	          SRID_UNKNOWN);
+	printf(
+	    _("USAGE: shp2pgsql [<options>] <shapefile> [[<schema>.]<table>]\n"
+	      "OPTIONS:\n"
+	      "  Long options with values also accept --option=value.\n"));
+	printf(_("  -s, --srid [<from>:]<srid> Set the SRID field. Defaults to %d.\n"
+		 "      Optionally reprojects from given SRID.\n"),
+	       SRID_UNKNOWN);
 	printf(_( " (-d|a|c|p) These are mutually exclusive options:\n"
 	          "     -d  Drops the table, then recreates it and populates\n"
 	          "         it with current shape file data.\n"
@@ -38,47 +122,53 @@ usage()
 	          "     -c  Creates a new table and populates it, this is the\n"
 	          "         default if you do not specify any options.\n"
 	          "     -p  Prepare mode, only creates the table.\n" ));
-	printf(_( "  -g <geocolumn> Specify the name of the geometry/geography column\n"
-	          "      (mostly useful in append mode).\n" ));
-	printf(_( "  -D  Use postgresql dump format (defaults to SQL insert statements).\n" ));
+	printf(
+	    _("  -g, --geometry-column <geocolumn> Specify the name of the geometry/geography column\n"
+	      "      (mostly useful in append mode).\n"));
+	printf(_("  -D, --dump-format  Use postgresql dump format (defaults to SQL insert statements).\n"));
 	printf(_( "  -e  Execute each statement individually, do not use a transaction.\n"
 	          "      Not compatible with -D.\n" ));
-	printf(_( "  -G  Use geography type (requires lon/lat data or -s to reproject).\n" ));
-	printf(_( "  -k  Keep postgresql identifiers case.\n" ));
-	printf(_( "  -i  Use int4 type for all integer dbf fields.\n" ));
+	printf(_("  -G, --geography  Use geography type (requires lon/lat data or -s to reproject).\n"));
+	printf(_("  -k, --keep-case  Keep postgresql identifiers case.\n"));
+	printf(_("  -i, --force-int4  Use int4 type for all integer dbf fields.\n"));
 	printf(_( "  -I  Create a spatial index on the geocolumn.\n" ));
 	printf(_("  --create-index  Create a spatial index on the geocolumn.\n"));
-	printf(_( "  -u  Create the table as UNLOGGED.\n" ));
-	printf(_("  -m <filename>  Specify a file containing a set of mappings of (long) column\n"
-	         "     names to 10 character DBF column names. The content of the file is one or\n"
-	         "     more lines of two names separated by white space and no trailing or\n"
-	         "     leading space. For example:\n"
-	         "         COLUMNNAME DBFFIELD1\n"
-	         "         AVERYLONGCOLUMNNAME DBFFIELD2\n" ));
-	printf(_( "  -S  Generate simple geometries instead of MULTI geometries.\n" ));
-	printf(_( "  -t <dimensionality> Force geometry to be one of '2D', '3DZ', '3DM', or '4D'\n" ));
+	printf(_("  -u, --unlogged  Create the table as UNLOGGED.\n"));
+	printf(
+	    _("  -m, --column-map <filename>  Specify a file containing a set of mappings of (long) column\n"
+	      "     names to 10 character DBF column names. The content of the file is one or\n"
+	      "     more lines of two names separated by white space and no trailing or\n"
+	      "     leading space. For example:\n"
+	      "         COLUMNNAME DBFFIELD1\n"
+	      "         AVERYLONGCOLUMNNAME DBFFIELD2\n"));
+	printf(_("  -S, --simple-geometries  Generate simple geometries instead of MULTI geometries.\n"));
+	printf(_("  -t, --dimensionality <dimensionality> Force geometry to be one of '2D', '3DZ', '3DM', or '4D'\n"));
 
-	printf(_( "  -w  Output WKT instead of WKB.  Note that this can result in\n"
-	          "      coordinate drift.\n" ));
-	printf(_( "  -W <encoding> Specify the character encoding of Shape's\n"
-	          "      attribute column. (default: \"UTF-8\")\n" ));
-	printf(_( "  -N <policy> NULL geometries handling policy (insert*,skip,abort).\n" ));
-	printf(_( "  -n  Only import DBF file.\n" ));
+	printf(
+	    _("  -w, --use-wkt  Output WKT instead of WKB.  Note that this can result in\n"
+	      "      coordinate drift.\n"));
+	printf(
+	    _("  -W, --encoding <encoding> Specify the character encoding of Shape's\n"
+	      "      attribute column. (default: \"UTF-8\")\n"));
+	printf(_("  -N, --null-policy <policy> NULL geometries handling policy (insert*,skip,abort).\n"));
+	printf(_("  -n, --dbf-only  Only import DBF file.\n"));
 	printf(_("  --drop-table  Drop the target table before the selected actions.\n"));
 	printf(_("  --create-table  Create the target table.\n"));
 	printf(_("  --if-not-exists  Make active creation actions use IF NOT EXISTS.\n"));
 	printf(_("  --load-data  Load shapefile rows into the target table.\n"));
-	printf(_( "  -T <tablespace> Specify the tablespace for the new table.\n"
-                  "      Note that indexes will still use the default tablespace unless the\n"
-                  "      -X flag is also used.\n"));
-	printf(_( "  -X <tablespace> Specify the tablespace for the table's indexes.\n"
-                  "      This applies to the primary key, and the spatial index if\n"
-                  "      the -I flag is used.\n" ));
+	printf(
+	    _("  -T, --tablespace <tablespace> Specify the tablespace for the new table.\n"
+	      "      Note that indexes will still use the default tablespace unless the\n"
+	      "      -X flag is also used.\n"));
+	printf(
+	    _("  -X, --index-tablespace <tablespace> Specify the tablespace for the table's indexes.\n"
+	      "      This applies to the primary key, and the spatial index if\n"
+	      "      the -I flag is used.\n"));
 	printf(_( "  -Z  Prevent tables from being analyzed.\n" ));
 	printf(_("  --analyze  Analyze the table after loading.\n"));
 	printf(_("  --no-analyze  Prevent tables from being analyzed.\n"));
 	printf(_("  --no-transaction  Execute each statement individually.\n"));
-	printf(_( "  -?  Display this help screen.\n" ));
+	printf(_("  -?, --help  Display this help screen.\n"));
 	printf( "\n" );
 	printf(_( "  An argument of `--' disables further option processing.\n" ));
 	printf(_( "  (useful for unusual file names starting with '-')\n" ));
@@ -184,18 +274,23 @@ main (int argc, char **argv)
 		}
 		if (strncmp(argv[pgis_optind], "--", 2) == 0)
 		{
-			fprintf(stderr, "Unknown option: %s\n", argv[pgis_optind]);
-			usage();
-			exit(1);
+			if (!consume_long_option(argc, argv, &c))
+			{
+				fprintf(stderr, "Unknown option: %s\n", argv[pgis_optind]);
+				usage();
+				exit(1);
+			}
 		}
+		else
+		{
+			c = pgis_getopt(argc, argv, "-?acdeg:ikm:nps:t:uwDGIN:ST:W:X:Z");
+			if (c == EOF)
+				break;
 
-		c = pgis_getopt(argc, argv, "-?acdeg:ikm:nps:t:uwDGIN:ST:W:X:Z");
-		if (c == EOF)
-			break;
-
-		// can not do this inside the switch case
-		if ('-' == c)
-			break;
+			// can not do this inside the switch case
+			if ('-' == c)
+				break;
+		}
 
 		switch (c)
 		{
diff --git a/regress/loader/LongOptions.opts b/regress/loader/LongOptions.opts
index dc46a9b2d..28e5ec9db 100644
--- a/regress/loader/LongOptions.opts
+++ b/regress/loader/LongOptions.opts
@@ -1 +1 @@
---drop-table --create-table --load-data --create-index --if-not-exists --no-transaction --analyze
+--drop-table --create-table --load-data --create-index --if-not-exists --no-transaction --analyze --srid=0 --geometry-column=the_geom --encoding=UTF-8 --null-policy=insert --dimensionality=2D --simple-geometries --force-int4

commit c222d23c27f4225b403ac19bfe53cff2c557e1a0
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Jun 21 18:25:31 2026 +0400

    Add long option aliases to raster2pgsql
    
    Accept GNU-style long aliases for existing raster2pgsql command-line options, including --option=value spelling for value-taking options. Keep the recent loader action long options as the canonical action names, and preserve endian selector compatibility while still emitting NDR output.
    
    Closes #4658
    
    Closes https://github.com/postgis/postgis/pull/1029

diff --git a/NEWS b/NEWS
index 20209cb38..4fb4532c8 100644
--- a/NEWS
+++ b/NEWS
@@ -21,10 +21,11 @@ To take advantage of all postgis_sfcgal extension features SFCGAL 2.3+ is needed
 
 * New Features *
 
- - #1124, #2935, #4659, [loader] Rework loader arguments: shp2pgsql can
+ - #1124, #2935, #4658, #4659, [loader] Rework loader arguments: shp2pgsql can
           create UNLOGGED tables, shp2pgsql --drop-table can emit DROP TABLE
           before prepare output, raster2pgsql/shp2pgsql expose loader actions
-          as long options, and --if-not-exists makes creation actions idempotent
+          as long options, raster2pgsql accepts long aliases for existing
+          options, and --if-not-exists makes creation actions idempotent
           (Darafei Praliaskouski)
  - #4208, Add single-geometry variants of ST_MaxDistance and ST_LongestLine
           (Darafei Praliaskouski)
diff --git a/doc/man/raster2pgsql.1 b/doc/man/raster2pgsql.1
index 17fa7194d..2789b2174 100644
--- a/doc/man/raster2pgsql.1
+++ b/doc/man/raster2pgsql.1
@@ -17,27 +17,29 @@ files.
 .SH "OPTIONS"
 .LP
 The commandline options are:
+.LP
+Long options that take values also accept the \fB\-\-option=value\fR spelling.
 .TP
-\fB\-s\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
+\fB\-s\fR, \fB\-\-srid\fR [<\fIFROM_SRID\fR>:]<\fISRID\fR>
 Set the SRID field. If FROM_SRID is given, the input raster is treated as that
 source SRID before being transformed to SRID. If no SRID is provided, or if SRID
 is 0, raster metadata is used when possible.
 .TP
-\fB\-b\fR <\fIband\fR>
+\fB\-b\fR, \fB\-\-band\fR <\fIband\fR>
 Index, starting from 1, of the band to extract from the raster. Separate
 multiple band indexes with commas. Ranges can be written with a dash. If this
 option is omitted, all bands are extracted.
 .TP
-\fB\-t\fR <\fItile_size\fR>
+\fB\-t\fR, \fB\-\-tile\-size\fR <\fItile_size\fR>
 Cut each raster into tiles inserted one per table row. The tile size is written
 as WIDTHxHEIGHT. Use "auto" to let the loader choose a tile size from the first
 raster and apply it to all rasters.
 .TP
-\fB\-P\fR
+\fB\-P\fR, \fB\-\-pad\fR
 Pad right-most and bottom-most tiles so all tiles have the same width and
 height.
 .TP
-\fB\-R\fR
+\fB\-R\fR, \fB\-\-register\fR
 Register the raster as an out-of-db filesystem raster. Input raster paths must
 be absolute.
 .TP
@@ -71,21 +73,21 @@ Create the target table.
 \fB\-\-load\-data\fR
 Load raster data into the target table.
 .TP
-\fB\-f\fR <\fIcolumn\fR>
+\fB\-f\fR, \fB\-\-raster\-column\fR <\fIcolumn\fR>
 Specify the name of the raster column.
 .TP
-\fB\-F\fR
+\fB\-F\fR, \fB\-\-filename\fR
 Add a column containing the source raster filename.
 .TP
-\fB\-n\fR <\fIcolumn\fR>
+\fB\-n\fR, \fB\-\-filename\-column\fR <\fIcolumn\fR>
 Specify the filename column name. This implies \-F.
 .TP
-\fB\-l\fR <\fIoverview_factor\fR>
+\fB\-l\fR, \fB\-\-overview\-factor\fR <\fIoverview_factor\fR>
 Create overview tables for the raster. Separate multiple factors with commas.
 Overview table names follow the pattern o_<overview factor>_<table>. Created
 overviews are stored in the database and are not affected by \-R.
 .TP
-\fB\-q\fR
+\fB\-q\fR, \fB\-\-quote\fR
 Wrap PostgreSQL identifiers in quotes.
 .TP
 \fB\-I\fR
@@ -114,48 +116,45 @@ constraints may fail if one or more input rasters violate the constraint.
 \fB\-\-add\-constraints\fR
 Set the standard raster constraints after the rasters are loaded.
 .TP
-\fB\-x\fR
+\fB\-x\fR, \fB\-\-no\-extent\fR
 Disable setting the max extent constraint. Only applies with \-C.
 .TP
-\fB\-r\fR
+\fB\-r\fR, \fB\-\-regular\-blocking\fR
 Set spatially unique and coverage tile constraints for regular blocking. Only
 applies with \-C.
 .TP
-\fB\-T\fR <\fItablespace\fR>
+\fB\-T\fR, \fB\-\-tablespace\fR <\fItablespace\fR>
 Specify the tablespace for the new table.
 .TP
-\fB\-X\fR <\fItablespace\fR>
+\fB\-X\fR, \fB\-\-index\-tablespace\fR <\fItablespace\fR>
 Specify the tablespace for the new table's indexes. This applies to the primary
 key and the spatial index when \-I is used.
 .TP
-\fB\-N\fR <\fInodata\fR>
+\fB\-N\fR, \fB\-\-nodata\fR <\fInodata\fR>
 NODATA value to use on bands without a NODATA value.
 .TP
-\fB\-k\fR
+\fB\-k\fR, \fB\-\-skip\-nodata\-check\fR
 Keep empty tiles by skipping NODATA value checks for each raster band.
 .TP
-\fB\-E\fR <\fIendian\fR>
+\fB\-E\fR, \fB\-\-endian\fR <\fIendian\fR>
 Control endianness of generated binary raster output. Use 0 for XDR and 1 for
 NDR. Only NDR is currently supported.
 .TP
-\fB\-V\fR <\fIversion\fR>
+\fB\-V\fR, \fB\-\-wkb\-version\fR <\fIversion\fR>
 Specify the output WKB format version. Only version 0 is currently supported.
 .TP
-\fB\-e\fR
+\fB\-e\fR, \fB\-\-no\-transaction\fR
 Execute each statement individually instead of wrapping the load in a
 transaction.
 .TP
-\fB\-\-no\-transaction\fR
-Execute statements individually, without using a transaction.
-.TP
-\fB\-Y\fR [<\fImax_rows_per_copy\fR>]
+\fB\-Y\fR, \fB\-\-copy\fR [<\fImax_rows_per_copy\fR>]
 Use COPY statements instead of INSERT statements. If no row limit is provided,
 50 rows are written per COPY.
 .TP
-\fB\-G\fR
+\fB\-G\fR, \fB\-\-gdal\-formats\fR
 Print the supported GDAL raster formats.
 .TP
-\fB\-?\fR
+\fB\-?\fR, \fB\-\-help\fR
 Display version and usage information.
 
 .SH "EXAMPLES"
diff --git a/doc/using_raster_dataman.xml b/doc/using_raster_dataman.xml
index a686de06e..97b60ab87 100644
--- a/doc/using_raster_dataman.xml
+++ b/doc/using_raster_dataman.xml
@@ -73,9 +73,13 @@ Available GDAL raster formats:
     <section>
       <title>raster2pgsql options</title>
 
+    <para>
+      Long options that take values also accept the <option>--option=value</option> spelling.
+    </para>
+
     <variablelist>
          <varlistentry>
-          <term><option>-?</option></term>
+          <term><option>-?, --help</option></term>
           <listitem>
             <para>
               Display help screen.  Help will also display if you don't pass in any arguments.
@@ -84,7 +88,7 @@ Available GDAL raster formats:
         </varlistentry>
 
        <varlistentry>
-          <term><option>-G</option></term>
+          <term><option>-G, --gdal-formats</option></term>
           <listitem>
             <para>
              Print the supported raster formats.
@@ -177,7 +181,7 @@ Available GDAL raster formats:
 				<para>
 					<variablelist>
 						<varlistentry>
-							<term><option>-C </option></term>
+							<term><option>-C, --add-constraints</option></term>
 							<listitem>
 								<para>
 									Apply raster constraints -- srid, pixelsize etc. to ensure raster is properly registered in <varname>raster_columns</varname> view.
@@ -185,18 +189,18 @@ Available GDAL raster formats:
 							</listitem>
 						</varlistentry>
 					   <varlistentry>
-							<term><option>-x </option></term>
+							<term><option>-x, --no-extent</option></term>
 							<listitem>
 								<para>
-									Disable setting the max extent constraint.  Only applied if -C flag is also used.
+									Disable setting the max extent constraint.  Only applied if -C or --add-constraints is also used.
 								</para>
 							</listitem>
 						</varlistentry>
 						<varlistentry>
-							<term><option>-r</option></term>
+							<term><option>-r, --regular-blocking</option></term>
 							<listitem>
 								<para>
-									Set the constraints (spatially unique and coverage tile) for regular blocking.  Only applied if -C flag is also used.
+									Set the constraints (spatially unique and coverage tile) for regular blocking.  Only applied if -C or --add-constraints is also used.
 								</para>
 							</listitem>
 						</varlistentry>
@@ -211,7 +215,7 @@ Available GDAL raster formats:
             <para>
             <variablelist>
                 <varlistentry>
-                    <term><option>-s [<FROM_SRID>:]<SRID></option></term>
+                    <term><option>-s, --srid [<FROM_SRID>:]<SRID></option></term>
                     <listitem>
                         <para>
                             Assign the output raster to the specified SRID.  When FROM_SRID is also provided, raster2pgsql marks the input raster with FROM_SRID and emits SQL that reprojects the raster to the target SRID.  If the source SRID is omitted or is zero, the raster metadata will be checked to determine an appropriate source SRID.  Reprojection cannot be used with copy mode.
@@ -220,7 +224,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                    <term><option>-b BAND</option></term>
+                    <term><option>-b, --band BAND</option></term>
                     <listitem>
                         <para>
                            Index (1-based) of band to extract from raster.  For more than one band index, separate with comma (,).  If unspecified,
@@ -230,7 +234,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                    <term><option>-t TILE_SIZE</option></term>
+                    <term><option>-t, --tile-size TILE_SIZE</option></term>
                     <listitem>
                         <para>
                             Cut raster into tiles to be inserted one per table row.  <varname>TILE_SIZE</varname> is expressed as WIDTHxHEIGHT or set to the value "auto" to allow the loader to compute an appropriate tile size using the first raster and applied to all rasters.
@@ -239,7 +243,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                    <term><option>-P</option></term>
+                    <term><option>-P, --pad</option></term>
                     <listitem>
                         <para>
                             Pad right-most and bottom-most tiles to guarantee that all tiles
@@ -259,7 +263,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                    <term><option>-l OVERVIEW_FACTOR</option></term>
+                    <term><option>-l, --overview-factor OVERVIEW_FACTOR</option></term>
 										<listitem><para>Create overview of the raster.  For more than
      one factor, separate with comma(,).  Overview table name follows
 		 the pattern o_<varname>overview factor</varname>_<varname>table</varname>, where <varname>overview factor</varname> is a placeholder for numerical overview factor and <varname>table</varname> is replaced with the base table name.  Created overview is
@@ -268,7 +272,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
 								<varlistentry>
-									<term><option>-N NODATA</option></term>
+									<term><option>-N, --nodata NODATA</option></term>
 									<listitem>
 										<para>
 											NODATA value to use on bands without a NODATA value.
@@ -287,7 +291,7 @@ Available GDAL raster formats:
             <para>
               <variablelist>
                 <varlistentry>
-                  <term><option>-f COLUMN</option></term>
+                  <term><option>-f, --raster-column COLUMN</option></term>
                   <listitem>
                     <para>Specify name of destination raster column, default is 'rast'
                     </para>
@@ -295,21 +299,21 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                  <term><option>-F</option></term>
+                  <term><option>-F, --filename</option></term>
                   <listitem>
                     <para>Add a column with the name of the file</para>
                   </listitem>
                 </varlistentry>
 
                 <varlistentry>
-                  <term><option>-n COLUMN</option></term>
+                  <term><option>-n, --filename-column COLUMN</option></term>
                   <listitem>
                     <para>Specify the name of the filename column. Implies -F.</para>
                   </listitem>
                 </varlistentry>
 
                <varlistentry>
-                  <term><option>-q</option></term>
+                  <term><option>-q, --quote</option></term>
                   <listitem>
                     <para>Wrap PostgreSQL identifiers in quotes.</para>
                   </listitem>
@@ -348,7 +352,7 @@ Available GDAL raster formats:
 
 
                 <varlistentry>
-                  <term><option>-k</option></term>
+                  <term><option>-k, --skip-nodata-check</option></term>
                   <listitem>
                     <para>
                         Keeps empty tiles and skips NODATA value checks for each raster band.
@@ -359,7 +363,7 @@ Available GDAL raster formats:
 
 
                 <varlistentry>
-                  <term><option>-T tablespace</option></term>
+                  <term><option>-T, --tablespace tablespace</option></term>
                   <listitem>
                     <para>
                       Specify the tablespace for the new table.
@@ -370,7 +374,7 @@ Available GDAL raster formats:
                 </varlistentry>
 
                 <varlistentry>
-                  <term><option>-X tablespace</option></term>
+                  <term><option>-X, --index-tablespace tablespace</option></term>
                   <listitem>
                     <para>
                       Specify the tablespace for the table's new index.
@@ -380,8 +384,8 @@ Available GDAL raster formats:
                   </listitem>
                  </varlistentry>
 
-               <varlistentry>
-                  <term><option>-Y  max_rows_per_copy=50</option></term>
+                <varlistentry>
+                  <term><option>-Y, --copy [MAX_ROWS_PER_COPY]</option></term>
                   <listitem>
                     <para>
                       Use copy statements instead of insert statements.  Optionally specify <varname>max_rows_per_copy</varname>;
@@ -395,17 +399,17 @@ Available GDAL raster formats:
         </varlistentry>
 
         <varlistentry>
-            <term><option>-e</option></term>
+            <term><option>-e, --no-transaction</option></term>
             <listitem><para>Execute each statement individually, do not use a transaction.</para></listitem>
         </varlistentry>
 
         <varlistentry>
-            <term><option>-E ENDIAN</option></term>
+            <term><option>-E, --endian ENDIAN</option></term>
             <listitem><para>Control endianness of generated binary output of raster; specify 0 for XDR and 1 for NDR (default); only NDR output is supported now</para></listitem>
         </varlistentry>
 
         <varlistentry>
-            <term><option>-V version</option></term>
+            <term><option>-V, --wkb-version version</option></term>
             <listitem><para>Specify version of output format.  Default  is 0.  Only 0 is supported at this time.</para></listitem>
         </varlistentry>
     </variablelist>
diff --git a/raster/loader/raster2pgsql.c b/raster/loader/raster2pgsql.c
index 450474eb6..442511ae8 100644
--- a/raster/loader/raster2pgsql.c
+++ b/raster/loader/raster2pgsql.c
@@ -336,6 +336,33 @@ chartrim(const char *input, char *remove) {
 	return rtn;
 }
 
+static int
+option_matches(const char *arg, const char *shortopt, const char *longopt)
+{
+	size_t longopt_len;
+
+	if (CSEQUAL(arg, shortopt) || CSEQUAL(arg, longopt))
+		return 1;
+
+	longopt_len = strlen(longopt);
+	return strncmp(arg, longopt, longopt_len) == 0 && arg[longopt_len] == '=';
+}
+
+static char *
+option_value(int argc, char **argv, int *argit, const char *longopt)
+{
+	const size_t longopt_len = strlen(longopt);
+	char *arg = argv[*argit];
+
+	if (strncmp(arg, longopt, longopt_len) == 0 && arg[longopt_len] == '=')
+		return arg + longopt_len + 1;
+
+	if (*argit < argc - 1)
+		return argv[++(*argit)];
+
+	return NULL;
+}
+
 static void
 usage() {
 	printf(_("RELEASE: %s GDAL_VERSION=%d (%s)\n"), POSTGIS_LIB_VERSION, POSTGIS_GDAL_VERSION, xstr(POSTGIS_REVISION));
@@ -343,34 +370,31 @@ usage() {
 	    _("USAGE: raster2pgsql [<options>] <raster>[ <raster>[ ...]] [[<schema>.]<table>]\n"
 	      "  Multiple rasters can also be specified using wildcards (*,?).\n"
 	      "\n"
-	      "OPTIONS:\n"));
-	printf(_("  -s [<from>:]<srid> Set the SRID field. Defaults to %d.\n"
+	      "OPTIONS:\n"
+	      "  Long options with values also accept --option=value.\n"));
+	printf(_("  -s, --srid [<from>:]<srid> Set the SRID field. Defaults to %d.\n"
 		 "     Optionally reprojects from given SRID (cannot be used with -Y).\n"
 		 "     Raster's metadata will be checked to determine an appropriate SRID.\n"
 		 "     Metadata lookup is also used when %d is provided as from or target.\n"),
 	       SRID_UNKNOWN,
 	       SRID_UNKNOWN);
-	printf(_(
-		"  -b <band> Index (1-based) of band to extract from raster. For more\n"
-		"      than one band index, separate with comma (,). Ranges can be\n"
-		"      defined by separating with dash (-). If unspecified, all bands\n"
-		"      of raster will be extracted.\n"
-	));
-	printf(_(
-		"  -t <tile size> Cut raster into tiles to be inserted one per\n"
-		"      table row. <tile size> is expressed as WIDTHxHEIGHT.\n"
-		"      <tile size> can also be \"auto\" to allow the loader to compute\n"
-		"      an appropriate tile size using the first raster and applied to\n"
-		"      all rasters.\n"
-	));
-	printf(_(
-		"  -P Pad right-most and bottom-most tiles to guarantee that all tiles\n"
-		"     have the same width and height.\n"
-	));
-	printf(_(
-		"  -R  Register the raster as an out-of-db (filesystem) raster. Provided\n"
-		"      raster should have absolute path to the file\n"
-	));
+	printf(
+	    _("  -b, --band <band> Index (1-based) of band to extract from raster. For more\n"
+	      "      than one band index, separate with comma (,). Ranges can be\n"
+	      "      defined by separating with dash (-). If unspecified, all bands\n"
+	      "      of raster will be extracted.\n"));
+	printf(
+	    _("  -t, --tile-size <tile size> Cut raster into tiles to be inserted one per\n"
+	      "      table row. <tile size> is expressed as WIDTHxHEIGHT.\n"
+	      "      <tile size> can also be \"auto\" to allow the loader to compute\n"
+	      "      an appropriate tile size using the first raster and applied to\n"
+	      "      all rasters.\n"));
+	printf(
+	    _("  -P, --pad Pad right-most and bottom-most tiles to guarantee that all tiles\n"
+	      "     have the same width and height.\n"));
+	printf(
+	    _("  -R, --register Register the raster as an out-of-db (filesystem) raster. Provided\n"
+	      "      raster should have absolute path to the file\n"));
 	printf(
 	    _(" (-d|a|c|p) These are mutually exclusive options:\n"
 	      "     -d  Drops the table, then recreates it and populates\n"
@@ -394,28 +418,20 @@ usage() {
 	      "      at the end of this raster2pgsql run. With repeated -a append\n"
 	      "      runs, create the index on the final run or after loading; add\n"
 	      "      --if-not-exists to make reruns tolerate an existing index.\n"));
-	printf(_(
-		"  -f <column> Specify the name of the raster column\n"
-	));
-	printf(_(
-		"  -F  Add a column with the filename of the raster.\n"
-	));
-	printf(_(
-		"  -n <column> Specify the name of the filename column. Implies -F.\n"
-	));
-	printf(_(
-		"  -l <overview factor> Create overview of the raster. For more than\n"
-		"      one factor, separate with comma(,). Overview table name follows\n"
-		"      the pattern o_<overview factor>_<table>. Created overview is\n"
-		"      stored in the database and is not affected by -R.\n"
-	));
-	printf(_(
-		"  -q  Wrap PostgreSQL identifiers in quotes.\n"
-	));
+	printf(_("  -f, --raster-column <column> Specify the name of the raster column\n"));
+	printf(_("  -F, --filename Add a column with the filename of the raster.\n"));
+	printf(_("  -n, --filename-column <column> Specify the name of the filename column. Implies -F.\n"));
+	printf(
+	    _("  -l, --overview-factor <overview factor> Create overview of the raster. For more than\n"
+	      "      one factor, separate with comma(,). Overview table name follows\n"
+	      "      the pattern o_<overview factor>_<table>. Created overview is\n"
+	      "      stored in the database and is not affected by -R.\n"));
+	printf(_("  -q, --quote Wrap PostgreSQL identifiers in quotes.\n"));
 	printf(_("  -I  Alias for --create-index.\n"));
 	printf(
 	    _("  --add-constraints  Set the standard set of constraints on the\n"
-	      "      raster column after the rasters are loaded.\n"
+	      "      raster column after the rasters are loaded. Some constraints may\n"
+	      "      fail if one or more rasters violate the constraint.\n"
 	      "  --vacuum  Run VACUUM on the table of the raster column.\n"
 	      "  --analyze  Run ANALYZE on the table of the raster column.\n"
 	      "  --no-transaction  Execute statements without a transaction.\n"));
@@ -423,54 +439,37 @@ usage() {
 		"  -M  Run VACUUM ANALYZE on the table of the raster column. Most\n"
 		"      useful when appending raster to existing table with -a.\n"
 	));
-	printf(_(
-		"  -C  Set the standard set of constraints on the raster\n"
-		"      column after the rasters are loaded. Some constraints may fail\n"
-		"      if one or more rasters violate the constraint.\n"
-		"  -x  Disable setting the max extent constraint. Only applied if\n"
-		"      -C flag is also used.\n"
-		"  -r  Set the constraints (spatially unique and coverage tile) for\n"
-		"      regular blocking. Only applied if -C flag is also used.\n"
-	));
-	printf(_(
-		"  -T <tablespace> Specify the tablespace for the new table.\n"
-		"      Note that indices (including the primary key) will still use\n"
-		"      the default tablespace unless the -X flag is also used.\n"
-	));
-	printf(_(
-		"  -X <tablespace> Specify the tablespace for the table's new index.\n"
-		"      This applies to the primary key and the spatial index if\n"
-		"      the -I flag is used.\n"
-	));
-	printf(_(
-		"  -N <nodata> NODATA value to use on bands without a NODATA value.\n"
-	));
-	printf(_(
-		"  -k  Keep empty tiles by skipping NODATA value checks for each raster band. \n"
-	));
-	printf(_(
-		"  -E <endian> Control endianness of generated binary output of\n"
-		"      raster. Use 0 for XDR and 1 for NDR (default). Only NDR\n"
-		"      is supported at this time.\n"
-	));
-	printf(_(
-		"  -V <version> Specify version of output WKB format. Default\n"
-		"      is 0. Only 0 is supported at this time.\n"
-	));
-	printf(_(
-		"  -e  Execute each statement individually, do not use a transaction.\n"
-	));
-	printf(_(
-		"  -Y <max_rows_per_copy> Use COPY statements instead of INSERT statements. \n"
-		"    Optionally specify <max_rows_per_copy>; default 50 when not specified. \n"
-	));
+	printf(
+	    _("  -C  Alias for --add-constraints.\n"
+	      "  -x, --no-extent Disable setting the max extent constraint. Only applied if\n"
+	      "      -C/--add-constraints is also used.\n"
+	      "  -r, --regular-blocking Set the constraints (spatially unique and coverage tile) for\n"
+	      "      regular blocking. Only applied if -C/--add-constraints is also used.\n"));
+	printf(
+	    _("  -T, --tablespace <tablespace> Specify the tablespace for the new table.\n"
+	      "      Note that indices (including the primary key) will still use\n"
+	      "      the default tablespace unless the -X flag is also used.\n"));
+	printf(
+	    _("  -X, --index-tablespace <tablespace> Specify the tablespace for the table's new index.\n"
+	      "      This applies to the primary key and the spatial index if\n"
+	      "      the -I flag is used.\n"));
+	printf(_("  -N, --nodata <nodata> NODATA value to use on bands without a NODATA value.\n"));
+	printf(
+	    _("  -k, --skip-nodata-check Keep empty tiles by skipping NODATA value checks for each raster band. \n"));
+	printf(
+	    _("  -E, --endian <endian> Control endianness of generated binary output of\n"
+	      "      raster. Use 0 for XDR and 1 for NDR (default). Only NDR\n"
+	      "      is supported at this time.\n"));
+	printf(
+	    _("  -V, --wkb-version <version> Specify version of output WKB format. Default\n"
+	      "      is 0. Only 0 is supported at this time.\n"));
+	printf(_("  -e, --no-transaction Execute each statement individually, do not use a transaction.\n"));
+	printf(
+	    _("  -Y, --copy [<max_rows_per_copy>] Use COPY statements instead of INSERT statements. \n"
+	      "    Optionally specify <max_rows_per_copy>; default 50 when not specified. \n"));
 
-	printf(_(
-		"  -G  Print the supported GDAL raster formats.\n"
-	));
-	printf(_(
-		"  -?  Display this help screen.\n"
-	));
+	printf(_("  -G, --gdal-formats Print the supported GDAL raster formats.\n"));
+	printf(_("  -?, --help Display this help screen.\n"));
 }
 
 static void
@@ -2450,8 +2449,9 @@ main(int argc, char **argv) {
 		char *optarg, *ptr;
 		/* srid */
 
-		if (CSEQUAL(argv[argit], "-s") && argit < argc - 1) {
-			optarg = argv[++argit];
+		if (option_matches(argv[argit], "-s", "--srid") &&
+		    (optarg = option_value(argc, argv, &argit, "--srid")) != NULL)
+		{
 			ptr = strchr(optarg, ':');
 			if (ptr) {
 				*ptr++ = '\0';
@@ -2462,8 +2462,10 @@ main(int argc, char **argv) {
 			}
 		}
 		/* band index */
-		else if (CSEQUAL(argv[argit], "-b") && argit < argc - 1) {
-			elements = strsplit(argv[++argit], ",", &n);
+		else if (option_matches(argv[argit], "-b", "--band") &&
+			 (optarg = option_value(argc, argv, &argit, "--band")) != NULL)
+		{
+			elements = strsplit(optarg, ",", &n);
 			if (n < 1) {
 				rterror(_("Could not process -b"));
 				rtdealloc_config(config);
@@ -2556,13 +2558,16 @@ main(int argc, char **argv) {
 			}
 		}
 		/* tile size */
-		else if (CSEQUAL(argv[argit], "-t") && argit < argc - 1) {
-			if (CSEQUAL(argv[++argit], "auto")) {
+		else if (option_matches(argv[argit], "-t", "--tile-size") &&
+			 (optarg = option_value(argc, argv, &argit, "--tile-size")) != NULL)
+		{
+			if (CSEQUAL(optarg, "auto"))
+			{
 				config->tile_size[0] = -1;
 				config->tile_size[1] = -1;
 			}
 			else {
-				elements = strsplit(argv[argit], "x", &n);
+				elements = strsplit(optarg, "x", &n);
 				if (n != 2) {
 					rterror(_("Could not process -t"));
 					rtdealloc_config(config);
@@ -2589,11 +2594,13 @@ main(int argc, char **argv) {
 			}
 		}
 		/* pad tiles */
-		else if (CSEQUAL(argv[argit], "-P")) {
+		else if (CSEQUAL(argv[argit], "-P") || CSEQUAL(argv[argit], "--pad"))
+		{
 			config->pad_tile = 1;
 		}
 		/* out-of-db raster */
-		else if (CSEQUAL(argv[argit], "-R")) {
+		else if (CSEQUAL(argv[argit], "-R") || CSEQUAL(argv[argit], "--register"))
+		{
 			config->outdb = 1;
 		}
 		/* drop table and recreate */
@@ -2640,35 +2647,42 @@ main(int argc, char **argv) {
 			config->actions.load_data_set = 1;
 		}
 		/* raster column name */
-		else if (CSEQUAL(argv[argit], "-f") && argit < argc - 1) {
-			const size_t len = (strlen(argv[++argit]) + 1);
+		else if (option_matches(argv[argit], "-f", "--raster-column") &&
+			 (optarg = option_value(argc, argv, &argit, "--raster-column")) != NULL)
+		{
+			const size_t len = (strlen(optarg) + 1);
 			config->raster_column = rtalloc(sizeof(char) * len);
 			if (config->raster_column == NULL) {
 				rterror(_("Could not allocate memory for storing raster column name"));
 				rtdealloc_config(config);
 				exit(1);
 			}
-			strncpy(config->raster_column, argv[argit], len);
+			strncpy(config->raster_column, optarg, len);
 		}
 		/* filename column */
-		else if (CSEQUAL(argv[argit], "-F")) {
+		else if (CSEQUAL(argv[argit], "-F") || CSEQUAL(argv[argit], "--filename"))
+		{
 			config->file_column = 1;
 		}
 		/* filename column name */
-		else if (CSEQUAL(argv[argit], "-n") && argit < argc - 1) {
-			const size_t len = (strlen(argv[++argit]) + 1);
+		else if (option_matches(argv[argit], "-n", "--filename-column") &&
+			 (optarg = option_value(argc, argv, &argit, "--filename-column")) != NULL)
+		{
+			const size_t len = (strlen(optarg) + 1);
 			config->file_column_name = rtalloc(sizeof(char) * len);
 			if (config->file_column_name == NULL) {
 				rterror(_("Could not allocate memory for storing filename column name"));
 				rtdealloc_config(config);
 				exit(1);
 			}
-			strncpy(config->file_column_name, argv[argit], len);
+			strncpy(config->file_column_name, optarg, len);
 			config->file_column = 1;
 		}
 		/* overview factors */
-		else if (CSEQUAL(argv[argit], "-l") && argit < argc - 1) {
-			elements = strsplit(argv[++argit], ",", &n);
+		else if (option_matches(argv[argit], "-l", "--overview-factor") &&
+			 (optarg = option_value(argc, argv, &argit, "--overview-factor")) != NULL)
+		{
+			elements = strsplit(optarg, ",", &n);
 			if (n < 1) {
 				rterror(_("Could not process -l"));
 				rtdealloc_config(config);
@@ -2701,7 +2715,8 @@ main(int argc, char **argv) {
 			}
 		}
 		/* quote identifiers */
-		else if (CSEQUAL(argv[argit], "-q")) {
+		else if (CSEQUAL(argv[argit], "-q") || CSEQUAL(argv[argit], "--quote"))
+		{
 			config->quoteident = 1;
 		}
 		/* create index */
@@ -2744,52 +2759,80 @@ main(int argc, char **argv) {
 			config->actions.add_constraints = 1;
 		}
 		/* disable extent constraint */
-		else if (CSEQUAL(argv[argit], "-x")) {
+		else if (CSEQUAL(argv[argit], "-x") || CSEQUAL(argv[argit], "--no-extent"))
+		{
 			config->max_extent = 0;
 		}
 		/* enable regular_blocking */
-		else if (CSEQUAL(argv[argit], "-r")) {
+		else if (CSEQUAL(argv[argit], "-r") || CSEQUAL(argv[argit], "--regular-blocking"))
+		{
 			config->regular_blocking = 1;
 		}
 		/* tablespace of new table */
-		else if (CSEQUAL(argv[argit], "-T") && argit < argc - 1) {
-			const size_t len = (strlen(argv[++argit]) + 1);
+		else if (option_matches(argv[argit], "-T", "--tablespace") &&
+			 (optarg = option_value(argc, argv, &argit, "--tablespace")) != NULL)
+		{
+			const size_t len = (strlen(optarg) + 1);
 			config->tablespace = rtalloc(len);
 			if (config->tablespace == NULL) {
 				rterror(_("Could not allocate memory for storing tablespace of new table"));
 				rtdealloc_config(config);
 				exit(1);
 			}
-			strncpy(config->tablespace, argv[argit], len);
+			strncpy(config->tablespace, optarg, len);
 		}
 		/* tablespace of new index */
-		else if (CSEQUAL(argv[argit], "-X") && argit < argc - 1) {
-			const size_t len = (strlen(argv[++argit]) + 1);
+		else if (option_matches(argv[argit], "-X", "--index-tablespace") &&
+			 (optarg = option_value(argc, argv, &argit, "--index-tablespace")) != NULL)
+		{
+			const size_t len = (strlen(optarg) + 1);
 			config->idx_tablespace = rtalloc(len);
 			if (config->idx_tablespace == NULL) {
 				rterror(_("Could not allocate memory for storing tablespace of new indices"));
 				rtdealloc_config(config);
 				exit(1);
 			}
-			strncpy(config->idx_tablespace, argv[argit], len);
+			strncpy(config->idx_tablespace, optarg, len);
 		}
 		/* nodata value */
-		else if (CSEQUAL(argv[argit], "-N") && argit < argc - 1) {
+		else if (option_matches(argv[argit], "-N", "--nodata") &&
+			 (optarg = option_value(argc, argv, &argit, "--nodata")) != NULL)
+		{
 			config->hasnodata = 1;
-			config->nodataval = atof(argv[++argit]);
+			config->nodataval = atof(optarg);
 		}
 		/* skip NODATA value check for bands */
-		else if (CSEQUAL(argv[argit], "-k")) {
+		else if (CSEQUAL(argv[argit], "-k") || CSEQUAL(argv[argit], "--skip-nodata-check"))
+		{
 			config->skip_nodataval_check = 1;
 		}
 		/* endianness */
-		else if (CSEQUAL(argv[argit], "-E") && argit < argc - 1) {
-			config->endian = atoi(argv[++argit]);
+		else if (option_matches(argv[argit], "-E", "--endian") &&
+			 (optarg = option_value(argc, argv, &argit, "--endian")) != NULL)
+		{
+			char *endptr = NULL;
+			const long endian = strtol(optarg, &endptr, 10);
+			if (*optarg == '\0' || *endptr != '\0' || (endian != 0 && endian != 1))
+			{
+				rterror(_(
+				    "Endian value must be 0 (XDR) or 1 (NDR); only NDR output is supported at this time"));
+				rtdealloc_config(config);
+				exit(1);
+			}
 			config->endian = 1;
 		}
 		/* version */
-		else if (CSEQUAL(argv[argit], "-V") && argit < argc - 1) {
-			config->version = atoi(argv[++argit]);
+		else if (option_matches(argv[argit], "-V", "--wkb-version") &&
+			 (optarg = option_value(argc, argv, &argit, "--wkb-version")) != NULL)
+		{
+			char *endptr = NULL;
+			const long version = strtol(optarg, &endptr, 10);
+			if (*optarg == '\0' || *endptr != '\0' || version != 0)
+			{
+				rterror(_("Only WKB version 0 is supported at this time"));
+				rtdealloc_config(config);
+				exit(1);
+			}
 			config->version = 0;
 		}
 		/* transaction */
@@ -2807,10 +2850,25 @@ main(int argc, char **argv) {
 			exit(1);
 		}
 		/* COPY statements */
-		else if (CSEQUAL(argv[argit], "-Y")) {
+		else if (option_matches(argv[argit], "-Y", "--copy"))
+		{
 			config->copy_statements = 1;
+			if (strncmp(argv[argit], "--copy=", strlen("--copy=")) == 0)
+			{
+				char *endptr = NULL;
+				const long max_tiles_per_copy = strtol(argv[argit] + strlen("--copy="), &endptr, 10);
+				optarg = argv[argit] + strlen("--copy=");
+				if (*optarg == '\0' || *endptr != '\0' || max_tiles_per_copy < 1)
+				{
+					rterror(_("--copy row limit must be greater than 0"));
+					rtdealloc_config(config);
+					exit(1);
+				}
+				config->max_tiles_per_copy = (int)max_tiles_per_copy;
+			}
 			/* max tiles per copy */
-			if ( argit < argc - 1) {
+			else if (argit < argc - 1)
+			{
 				optarg = argv[argit + 1];
 				if (atoi(optarg) > 0 ) {
 					config->max_tiles_per_copy = atoi(optarg);
@@ -2819,9 +2877,9 @@ main(int argc, char **argv) {
 			}
 		}
 
-
 		/* GDAL formats */
-		else if (CSEQUAL(argv[argit], "-G")) {
+		else if (CSEQUAL(argv[argit], "-G") || CSEQUAL(argv[argit], "--gdal-formats"))
+		{
 			uint32_t drv_count = 0;
 			rt_gdaldriver drv_set = rt_raster_gdal_drivers(&drv_count, 0);
 			if (drv_set == NULL || !drv_count) {
@@ -2843,7 +2901,8 @@ main(int argc, char **argv) {
 			exit(0);
 		}
 		/* help */
-		else if (CSEQUAL(argv[argit], "-?")) {
+		else if (CSEQUAL(argv[argit], "-?") || CSEQUAL(argv[argit], "--help"))
+		{
 			usage();
 			rtdealloc_config(config);
 			exit(0);
diff --git a/raster/test/regress/loader/LongMaintenance.opts b/raster/test/regress/loader/LongMaintenance.opts
index e63937728..4841db97c 100644
--- a/raster/test/regress/loader/LongMaintenance.opts
+++ b/raster/test/regress/loader/LongMaintenance.opts
@@ -1 +1 @@
---add-constraints --vacuum --analyze
+--add-constraints --vacuum --analyze --copy=20 --srid=0 --band=1-3 --tile-size=90x50 --raster-column=rast
diff --git a/raster/test/regress/loader/LongMaintenance.select.sql b/raster/test/regress/loader/LongMaintenance.select.sql
index 18027ebe8..efe793db4 100644
--- a/raster/test/regress/loader/LongMaintenance.select.sql
+++ b/raster/test/regress/loader/LongMaintenance.select.sql
@@ -1,5 +1,7 @@
+-- This test combines long action options with GNU-style long value options.
 -- --add-constraints should register the loaded raster in raster_columns
--- with the same metadata that the existing short -C test expects.
+-- with the same metadata that the existing short -C test expects, while the
+-- 90x50 tile and sampled band values prove that --tile-size and --band parsed.
 SELECT srid, scale_x::numeric(16, 10), scale_y::numeric(16, 10), blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values::numeric(16,10)[], out_db, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'loadedrast' AND r_raster_column = 'rast';
 
 -- The raster data should survive the long maintenance path unchanged.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                               |   5 +-
 doc/man/raster2pgsql.1                             |  49 ++--
 doc/man/shp2pgsql.1                                |  43 +--
 doc/using_raster_dataman.xml                       |  54 ++--
 loader/shp2pgsql-cli.c                             | 183 +++++++++---
 raster/loader/raster2pgsql.c                       | 315 ++++++++++++---------
 raster/test/regress/loader/LongMaintenance.opts    |   2 +-
 .../test/regress/loader/LongMaintenance.select.sql |   4 +-
 regress/loader/LongOptions.opts                    |   2 +-
 9 files changed, 411 insertions(+), 246 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list