]> granicus.if.org Git - postgis/commitdiff
Remove use of lwerror in postgis/ directory, replace
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 7 Sep 2017 13:40:42 +0000 (13:40 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 7 Sep 2017 13:40:42 +0000 (13:40 +0000)
with PgSQL elog() calls instead.

git-svn-id: http://svn.osgeo.org/postgis/trunk@15655 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geobuf.c
postgis/lwgeom_out_geobuf.c
postgis/lwgeom_out_mvt.c
postgis/lwgeom_sfcgal.c
postgis/mvt.c

index 1e5cbe365a827b1c4af78b2e10090033350ce164..ea68752f4a2a2a842578cd782d56c63af16958a3 100644 (file)
@@ -72,7 +72,7 @@ static void encode_keys(struct geobuf_agg_context *ctx)
                keys[k++] = key;
        }
        if (!geom_name_found)
-               lwerror("encode_keys: no column with specificed geom_name found");
+               elog(ERROR, "encode_keys: no column with specificed geom_name found");
        ctx->data->n_keys = k;
        ctx->data->keys = keys;
        ReleaseTupleDesc(tupdesc);
@@ -422,7 +422,7 @@ static Data__Geometry *encode_geometry(struct geobuf_agg_context *ctx,
        case COLLECTIONTYPE:
                return encode_collection(ctx, (LWCOLLECTION*)lwgeom);
        default:
-               lwerror("encode_geometry: '%s' geometry type not supported",
+               elog(ERROR, "encode_geometry: '%s' geometry type not supported",
                                lwtype_name(type));
        }
        return NULL;
@@ -477,7 +477,7 @@ static void analyze_geometry(struct geobuf_agg_context *ctx, LWGEOM *lwgeom)
                        analyze_geometry(ctx, lwcollection->geoms[i]);
                break;
        default:
-               lwerror("analyze_geometry: '%s' geometry type not supported",
+               elog(ERROR, "analyze_geometry: '%s' geometry type not supported",
                        lwtype_name(type));
        }
 }
@@ -571,7 +571,7 @@ void geobuf_agg_transfn(struct geobuf_agg_context *ctx)
 
        datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
        if (!datum)
-               lwerror("geobuf_agg_transfn: geometry column cannot be null");
+               elog(ERROR, "geobuf_agg_transfn: geometry column cannot be null");
        gs = (GSERIALIZED *) PG_DETOAST_DATUM_COPY(datum);
        lwgeom = lwgeom_from_gserialized(gs);
 
index 30aaf5ee757dd36f86f525f279eb7a9ca3ab77e8..a4e1745f6729cb17f24b4a98659bd0d0fabf8a3d 100644 (file)
@@ -46,20 +46,20 @@ PG_FUNCTION_INFO_V1(pgis_asgeobuf_transfn);
 Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
 {
 #ifndef HAVE_LIBPROTOBUF
-       lwerror("Missing libprotobuf-c");
+       elog(ERROR, "Missing libprotobuf-c");
        PG_RETURN_NULL();
 #else
        MemoryContext aggcontext;
        struct geobuf_agg_context *ctx;
 
        if (!AggCheckCallContext(fcinfo, &aggcontext))
-               lwerror("pgis_asmvt_transfn: called in non-aggregate context");
+               elog(ERROR, "pgis_asmvt_transfn: called in non-aggregate context");
        MemoryContextSwitchTo(aggcontext);
 
        if (PG_ARGISNULL(0)) {
                ctx = palloc(sizeof(*ctx));
                if (PG_ARGISNULL(1))
-                       lwerror("pgis_asgeobuf_transfn: parameter geom_name cannot be null");
+                       elog(ERROR, "pgis_asgeobuf_transfn: parameter geom_name cannot be null");
                ctx->geom_name = text_to_cstring(PG_GETARG_TEXT_P(1));
                geobuf_agg_init_context(ctx);
        } else {
@@ -67,7 +67,7 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
        }
 
        if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 2)))
-               lwerror("pgis_asgeobuf_transfn: parameter row cannot be other than a rowtype");
+               elog(ERROR, "pgis_asgeobuf_transfn: parameter row cannot be other than a rowtype");
        ctx->row = PG_GETARG_HEAPTUPLEHEADER(2);
 
        geobuf_agg_transfn(ctx);
@@ -82,12 +82,12 @@ PG_FUNCTION_INFO_V1(pgis_asgeobuf_finalfn);
 Datum pgis_asgeobuf_finalfn(PG_FUNCTION_ARGS)
 {
 #ifndef HAVE_LIBPROTOBUF
-       lwerror("Missing libprotobuf-c");
+       elog(ERROR, "Missing libprotobuf-c");
        PG_RETURN_NULL();
 #else
        struct geobuf_agg_context *ctx;
        if (!AggCheckCallContext(fcinfo, NULL))
-               lwerror("pgis_asmvt_finalfn called in non-aggregate context");
+               elog(ERROR, "pgis_asmvt_finalfn called in non-aggregate context");
 
        if (PG_ARGISNULL(0))
                PG_RETURN_NULL();
index 107ce428e096aea00d7a97a3ab7fc44520870081..32ea006ee84903003c2118c858a88b645bd81187 100644 (file)
@@ -42,7 +42,7 @@ PG_FUNCTION_INFO_V1(ST_AsMVTGeom);
 Datum ST_AsMVTGeom(PG_FUNCTION_ARGS)
 {
 #ifndef HAVE_LIBPROTOBUF
-       lwerror("Missing libprotobuf-c");
+       elog(ERROR, "Missing libprotobuf-c");
        PG_RETURN_NULL();
 #else
        LWGEOM *lwgeom_in, *lwgeom_out;
@@ -51,11 +51,11 @@ Datum ST_AsMVTGeom(PG_FUNCTION_ARGS)
        int extent, buffer;
        bool clip_geom;
        if (PG_ARGISNULL(0))
-               lwerror("ST_AsMVTGeom: geom cannot be null");
+               elog(ERROR, "ST_AsMVTGeom: geom cannot be null");
        geom_in = PG_GETARG_GSERIALIZED_P(0);
        lwgeom_in = lwgeom_from_gserialized(geom_in);
        if (PG_ARGISNULL(1))
-               lwerror("ST_AsMVTGeom: parameter bounds cannot be null");
+               elog(ERROR, "ST_AsMVTGeom: parameter bounds cannot be null");
        bounds = (GBOX *) PG_GETARG_POINTER(1);
        extent = PG_ARGISNULL(2) ? 4096 : PG_GETARG_INT32(2);
        buffer = PG_ARGISNULL(3) ? 0 : PG_GETARG_INT32(3);
@@ -78,26 +78,26 @@ PG_FUNCTION_INFO_V1(pgis_asmvt_transfn);
 Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS)
 {
 #ifndef HAVE_LIBPROTOBUF
-       lwerror("Missing libprotobuf-c");
+       elog(ERROR, "Missing libprotobuf-c");
        PG_RETURN_NULL();
 #else
        MemoryContext aggcontext;
        struct mvt_agg_context *ctx;
 
        if (!AggCheckCallContext(fcinfo, &aggcontext))
-               lwerror("pgis_asmvt_transfn: called in non-aggregate context");
+               elog(ERROR, "pgis_asmvt_transfn: called in non-aggregate context");
        MemoryContextSwitchTo(aggcontext);
 
        if (PG_ARGISNULL(0)) {
                ctx = palloc(sizeof(*ctx));
                if (PG_ARGISNULL(1))
-                       lwerror("pgis_asmvt_transfn: parameter name cannot be null");
+                       elog(ERROR, "pgis_asmvt_transfn: parameter name cannot be null");
                text *name = PG_GETARG_TEXT_P(1);
                ctx->name = text_to_cstring(name);
                PG_FREE_IF_COPY(name, 1);
                ctx->extent = PG_ARGISNULL(2) ? 4096 : PG_GETARG_INT32(2);
                if (PG_ARGISNULL(3))
-                       lwerror("pgis_asmvt_transfn: parameter geom_name cannot be null");
+                       elog(ERROR, "pgis_asmvt_transfn: parameter geom_name cannot be null");
                text *geom_name = PG_GETARG_TEXT_P(3);
                ctx->geom_name = text_to_cstring(geom_name);
                PG_FREE_IF_COPY(geom_name, 3);
@@ -107,7 +107,7 @@ Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS)
        }
 
        if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 4)))
-               lwerror("pgis_asmvt_transfn: parameter row cannot be other than a rowtype");
+               elog(ERROR, "pgis_asmvt_transfn: parameter row cannot be other than a rowtype");
        ctx->row = PG_GETARG_HEAPTUPLEHEADER(4);
 
        mvt_agg_transfn(ctx);
@@ -123,12 +123,12 @@ PG_FUNCTION_INFO_V1(pgis_asmvt_finalfn);
 Datum pgis_asmvt_finalfn(PG_FUNCTION_ARGS)
 {
 #ifndef HAVE_LIBPROTOBUF
-       lwerror("Missing libprotobuf-c");
+       elog(ERROR, "Missing libprotobuf-c");
        PG_RETURN_NULL();
 #else
        struct mvt_agg_context *ctx;
        if (!AggCheckCallContext(fcinfo, NULL))
-               lwerror("pgis_asmvt_finalfn called in non-aggregate context");
+               elog(ERROR, "pgis_asmvt_finalfn called in non-aggregate context");
 
        if (PG_ARGISNULL(0))
                PG_RETURN_NULL();
index 3a3f5144df2f8f0d18f70ba713c96024a2d19ed8..da7772e9a7ffdd3b21d1b4e9924f94e66bfec40a 100644 (file)
@@ -734,7 +734,7 @@ Datum sfcgal_is_solid(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(input, 0);
        if (! lwgeom)
        {
-               lwerror("sfcgal_is_solid: Unable to deserialize input");
+               elog(ERROR, "sfcgal_is_solid: Unable to deserialize input");
        }
         result = FLAGS_GET_SOLID( lwgeom->flags );
 
@@ -752,7 +752,7 @@ Datum sfcgal_make_solid(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(input, 0);
        if (! lwgeom)
        {
-               lwerror("sfcgal_make_solid: Unable to deserialize input");
+               elog(ERROR, "sfcgal_make_solid: Unable to deserialize input");
        }
 
         FLAGS_SET_SOLID( lwgeom->flags, 1);
index 6668fa84b13c45b6cf2974edba6e339b9043978f..ddfe6db95d2970a9ce0292d6c7549eee93f49cc0 100644 (file)
@@ -262,7 +262,7 @@ static void encode_geometry(struct mvt_agg_context *ctx, LWGEOM *lwgeom)
                return encode_mline(ctx, (LWMLINE*)lwgeom);
        case MULTIPOLYGONTYPE:
                return encode_mpoly(ctx, (LWMPOLY*)lwgeom);
-       default: lwerror("encode_geometry: '%s' geometry type not supported",
+       default: elog(ERROR, "encode_geometry: '%s' geometry type not supported",
                lwtype_name(type));
        }
 }
@@ -325,7 +325,7 @@ static void parse_column_keys(struct mvt_agg_context *ctx)
                add_key(ctx, key);
        }
        if (!geom_name_found)
-               lwerror("parse_column_keys: no column '%s' found", ctx->geom_name);
+               elog(ERROR, "parse_column_keys: no column '%s' found", ctx->geom_name);
        ReleaseTupleDesc(tupdesc);
 }
 
@@ -570,17 +570,16 @@ static void parse_values(struct mvt_agg_context *ctx)
                }
 #if POSTGIS_PGSQL_VERSION >= 94
                if (k == -1 && typoid != JSONBOID)
-#else
-               if (k == -1)
-#endif
-                       lwerror("parse_values: unexpectedly could not find parsed key name",
-                               key);
-#if POSTGIS_PGSQL_VERSION >= 94
+                       elog(ERROR, "parse_values: unexpectedly could not find parsed key name '%s'", key);
                if (typoid == JSONBOID) {
                        tags = parse_jsonb(ctx, DatumGetJsonb(datum), tags);
                        continue;
                }
+#else
+               if (k == -1)
+                       elog(ERROR, "parse_values: unexpectedly could not find parsed key name '%s'", key);
 #endif
+
                switch (typoid) {
                case BOOLOID:
                        MVT_PARSE_DATUM(protobuf_c_boolean, mvt_kv_bool_value,
@@ -655,10 +654,10 @@ LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer,
        const GBOX *ggbox = lwgeom_get_bbox(lwgeom);
 
        if (width == 0 || height == 0)
-               lwerror("mvt_geom: bounds width or height cannot be 0");
+               elog(ERROR, "mvt_geom: bounds width or height cannot be 0");
 
        if (extent == 0)
-               lwerror("mvt_geom: extent cannot be 0");
+               elog(ERROR, "mvt_geom: extent cannot be 0");
 
        if (clip_geom) {
                GBOX *bgbox = gbox_copy(gbox);
@@ -744,7 +743,7 @@ void mvt_agg_init_context(struct mvt_agg_context *ctx)
        VectorTile__Tile__Layer *layer;
 
        if (ctx->extent == 0)
-               lwerror("mvt_agg_init_context: extent cannot be 0");
+               elog(ERROR, "mvt_agg_init_context: extent cannot be 0");
 
        ctx->features_capacity = FEATURES_CAPACITY_INITIAL;
        ctx->keys_hash = NULL;
@@ -800,7 +799,7 @@ void mvt_agg_transfn(struct mvt_agg_context *ctx)
        bool isnull;
        Datum datum = GetAttributeByNum(ctx->row, ctx->geom_index + 1, &isnull);
        if (!datum)
-               lwerror("mvt_agg_transfn: geometry column cannot be null");
+               elog(ERROR, "mvt_agg_transfn: geometry column cannot be null");
        GSERIALIZED *gs = (GSERIALIZED *) PG_DETOAST_DATUM(datum);
        LWGEOM *lwgeom = lwgeom_from_gserialized(gs);