[postgis-tickets] [SCM] PostGIS branch stable-2.5 updated. 2.5.8-4-g7f75bde03
git at osgeo.org
git at osgeo.org
Thu Nov 3 19:14:16 PDT 2022
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, stable-2.5 has been updated
via 7f75bde03efc80c9f7677a4bfe4dcf2fab1fc180 (commit)
from d745b7b97427122306e841ef79865148dadff3a0 (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 7f75bde03efc80c9f7677a4bfe4dcf2fab1fc180
Author: Regina Obe <lr at pcorp.us>
Date: Thu Nov 3 22:12:59 2022 -0400
shp2pgsql: Handle load of dbase character fields
with no width specified
Closes #5280 for PostGIS 2.5.9
diff --git a/NEWS b/NEWS
index 5564cdf18..64d24115c 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ xxxx/xx/xx
* Bug fixes *
- #5241, Crash on ST_SnapToGrid with empty multis (Regina Obe)
+ - #5280, shp2pgsql: Handle load of dbase character fields with no width
+ specified (Regina Obe)
PostGIS 2.5.8
2022/08/17
diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c
index 67ee0b039..aadbe016e 100644
--- a/loader/shp2pgsql-core.c
+++ b/loader/shp2pgsql-core.c
@@ -1367,9 +1367,10 @@ ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader)
/* First output the raw field type string */
stringbuffer_aprintf(sb, "%s", state->pgfieldtypes[j]);
- /* Some types do have typmods though... */
- if (!strcmp("varchar", state->pgfieldtypes[j]))
- stringbuffer_aprintf(sb, "(%d)", state->widths[j]);
+ /* Some types do have typmods */
+ /* Apply width typmod for varchar if there is positive width **/
+ if (!strcmp("varchar", state->pgfieldtypes[j]) && state->widths[j] > 0)
+ stringbuffer_aprintf(sb, "(%d)", state->widths[j]);
if (!strcmp("numeric", state->pgfieldtypes[j]))
{
diff --git a/regress/Makefile.in b/regress/Makefile.in
index 7ec544c89..47ac973c8 100644
--- a/regress/Makefile.in
+++ b/regress/Makefile.in
@@ -75,6 +75,7 @@ TESTS = \
loader/Latin1 \
loader/Latin1-implicit \
loader/mfile \
+ loader/CharNoWidth \
dumper/literalsrid \
dumper/realtable \
affine \
diff --git a/regress/loader/CharNoWidth.dbf b/regress/loader/CharNoWidth.dbf
new file mode 100644
index 000000000..9edcc7d04
Binary files /dev/null and b/regress/loader/CharNoWidth.dbf differ
diff --git a/regress/loader/CharNoWidth.select.expected b/regress/loader/CharNoWidth.select.expected
new file mode 100644
index 000000000..3cd81d490
--- /dev/null
+++ b/regress/loader/CharNoWidth.select.expected
@@ -0,0 +1,18 @@
+1|11|50000|02390665|1150000|Washington|Washington city|25|C5|||G4110|N|158316184|18709787|+38.9042474|-077.0165167
+aland|
+awater|
+classfp|2
+funcstat|1
+geoid|7
+gid|
+intptlat|11
+intptlon|12
+lsad|2
+mtfcc|5
+name|100
+namelsad|100
+pcicbsa|
+pcinecta|
+placefp|5
+placens|8
+statefp|2
diff --git a/regress/loader/CharNoWidth.select.sql b/regress/loader/CharNoWidth.select.sql
new file mode 100644
index 000000000..c7ccb2e01
--- /dev/null
+++ b/regress/loader/CharNoWidth.select.sql
@@ -0,0 +1,3 @@
+SET CLIENT_ENCODING to UTF8;
+SELECT * FROM loadedshp;
+SELECT column_name, character_maximum_length FROM information_schema.columns WHERE table_name = 'loadedshp' ORDER BY column_name;
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
loader/shp2pgsql-core.c | 7 ++++---
regress/Makefile.in | 1 +
regress/loader/CharNoWidth.dbf | Bin 0 -> 830 bytes
regress/loader/CharNoWidth.select.expected | 18 ++++++++++++++++++
regress/loader/CharNoWidth.select.sql | 3 +++
6 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 regress/loader/CharNoWidth.dbf
create mode 100644 regress/loader/CharNoWidth.select.expected
create mode 100644 regress/loader/CharNoWidth.select.sql
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list