[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-29-gd1a929f
git at osgeo.org
git at osgeo.org
Tue Mar 3 11:25:28 PST 2020
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 d1a929f3c9557156c2a4d4c1606487f4fe80b0cd (commit)
from 2534f03889c1d515b0dce2c437d79b4c51336a4e (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 d1a929f3c9557156c2a4d4c1606487f4fe80b0cd
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Mar 3 11:25:22 2020 -0800
treat an empty string in a date field as a NULL, references #4607
diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c
index 552ae0d..5480ebc 100644
--- a/loader/shp2pgsql-core.c
+++ b/loader/shp2pgsql-core.c
@@ -1641,6 +1641,14 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
case FTString:
case FTLogical:
+ rv = snprintf(val, MAXVALUELEN, "%s", DBFReadStringAttribute(state->hDBFHandle, item, i));
+ if (rv >= MAXVALUELEN || rv == -1)
+ {
+ stringbuffer_aprintf(sbwarn, "Warning: field %d name truncated\n", i);
+ val[MAXVALUELEN - 1] = '\0';
+ }
+ break;
+
case FTDate:
rv = snprintf(val, MAXVALUELEN, "%s", DBFReadStringAttribute(state->hDBFHandle, item, i));
if (rv >= MAXVALUELEN || rv == -1)
@@ -1648,6 +1656,14 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
stringbuffer_aprintf(sbwarn, "Warning: field %d name truncated\n", i);
val[MAXVALUELEN - 1] = '\0';
}
+ if (strlen(val) == 0)
+ {
+ if (state->config->dump_format)
+ stringbuffer_aprintf(sb, "\\N");
+ else
+ stringbuffer_aprintf(sb, "NULL");
+ goto done_cell;
+ }
break;
default:
@@ -1707,6 +1723,8 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
free(escval);
}
+done_cell:
+
/* Only put in delimeter if not last field or a shape will follow */
if (state->config->readshape == 1 || i < DBFGetFieldCount(state->hDBFHandle) - 1)
{
-----------------------------------------------------------------------
Summary of changes:
loader/shp2pgsql-core.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list