[postgis-tickets] [SCM] PostGIS branch stable-3.0 updated. 3.0.1-4-g6428d56

git at osgeo.org git at osgeo.org
Tue Mar 3 11:31:40 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, stable-3.0 has been updated
       via  6428d5678a3cc81e0f428c3a4d48ae2f1ae1c8ff (commit)
      from  5b4ee6673ccbda4b798889873c2f01210d054369 (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 6428d5678a3cc81e0f428c3a4d48ae2f1ae1c8ff
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Mar 3 11:31:36 2020 -0800

    treat empty string as NULL in case of Date, closes #4607

diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c
index 859b36d..5d5e92a 100644
--- a/loader/shp2pgsql-core.c
+++ b/loader/shp2pgsql-core.c
@@ -1643,6 +1643,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)
@@ -1650,6 +1658,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:
@@ -1709,6 +1725,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