- #4361, Fix postgis_type_name with (GEOMETRYM,3) (Matt Bretl)
- #4326, Fix circular arc distance calculation (Paul Ramsey)
+ - #4388, AddRasterConstraints: Ignore NULLs when generating constraints (Raúl Marín)
PostGIS 2.3.9
sql := 'SELECT st_srid('
|| quote_ident($3)
|| ') FROM ' || fqtn
- || ' LIMIT 1';
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
|| quote_ident($3)
|| ') FROM '
|| fqtn
- || ' LIMIT 1';
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
fqtn := fqtn || quote_ident($2);
sql := 'SELECT @extschema@.ST_SRID('
- || quote_ident($3)
- || ') FROM '
- || fqtn
- || ' LIMIT 1;';
- EXECUTE sql INTO srid;
+ || quote_ident($3)
+ || ') FROM '
+ || fqtn
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
+ EXECUTE sql INTO srid;
cn := 'enforce_max_extent_' || $3;
sql := 'SELECT @extschema@.st_makeemptyraster(1, 1, upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid) FROM @extschema@.st_metadata((SELECT '
|| quote_ident($3)
- || ' FROM ' || fqtn || ' LIMIT 1))';
+ || ' FROM '
+ || fqtn
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1))';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
cn := 'enforce_num_bands_' || $3;
sql := 'SELECT @extschema@.st_numbands(' || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
+ || ') FROM '
+ || fqtn
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
sql := 'SELECT @extschema@._raster_constraint_pixel_types(' || quote_ident($3)
|| ') FROM ' || fqtn
- || ' LIMIT 1';
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
sql := 'SELECT @extschema@._raster_constraint_nodata_values(' || quote_ident($3)
|| ') FROM ' || fqtn
- || ' LIMIT 1';
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
sql := 'SELECT @extschema@._raster_constraint_out_db(' || quote_ident($3)
|| ') FROM ' || fqtn
- || ' LIMIT 1';
+ || ' WHERE '
+ || quote_ident($3)
+ || ' IS NOT NULL LIMIT 1;';
BEGIN
EXECUTE sql INTO attr;
EXCEPTION WHEN OTHERS THEN
#3055 ST_Clip() on a raster without band crashes the server
******************************************************************************/
SELECT ST_SummaryStats(ST_Clip(ST_MakeEmptyRaster(42, 42, 0, 0, 1.0, 1.0, 0, 0, 4269), ST_MakeEnvelope(0, 0, 20, 20, 4269)));
+
+/**
+#4308,
+*/
+CREATE TABLE table_4308 (r raster);
+INSERT INTO table_4308(r) values (NULL);
+INSERT INTO table_4308(r) SELECT ST_AddBand(ST_MakeEmptyRaster(10, 10, 1, 1, 2, 2, 0, 0,4326), 1, '8BSI'::text, -129, NULL);;
+SELECT AddRasterConstraints('table_4308', 'r');
+DROP TABLE table_4308;
\ No newline at end of file
ERROR: new row for relation "test_raster_scale_small" violates check constraint "enforce_scaley_rast"
NOTICE: Input raster is empty or has no bands. Returning empty raster
NOTICE: Invalid band index (must use 1-based). Returning NULL
+NOTICE: Adding SRID constraint
+NOTICE: Adding scale-X constraint
+NOTICE: Adding scale-Y constraint
+NOTICE: Adding blocksize-X constraint
+NOTICE: Adding blocksize-Y constraint
+NOTICE: Adding alignment constraint
+NOTICE: Adding number of bands constraint
+NOTICE: Adding pixel type constraint
+NOTICE: Adding nodata value constraint
+NOTICE: Adding out-of-database constraint
+NOTICE: Adding maximum extent constraint
+t