68 static const uint16_t max_query_size = 512;
72 postgis_initialize_cache(fcinfo);
74 if (SPI_OK_CONNECT != SPI_connect ())
76 elog(NOTICE,
"getSRSbySRID: could not connect to SPI manager");
84 "SELECT auth_name||':'||auth_srid \
85 FROM %s WHERE srid='%d'",
86 postgis_spatial_ref_sys(),
91 "SELECT 'urn:ogc:def:crs:'||auth_name||'::'||auth_srid \
92 FROM %s WHERE srid='%d'",
93 postgis_spatial_ref_sys(),
96 err = SPI_exec(query, 1);
99 elog(NOTICE,
"getSRSbySRID: error executing query %d", err);
105 if (SPI_processed <= 0)
112 srs = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
122 size = strlen(srs)+1;
123 srscopy = SPI_palloc(size);
124 memcpy(srscopy, srs, size);