MCPcopy Index your code
hub / github.com/MapServer/MapServer / msPostGISLayerOpen

Function msPostGISLayerOpen

mappostgis.c:2160–2283  ·  view source on GitHub ↗

** msPostGISLayerOpen() ** ** Registered vtable->LayerOpen function. */

Source from the content-addressed store, hash-verified

2158** Registered vtable->LayerOpen function.
2159*/
2160int msPostGISLayerOpen(layerObj *layer) {
2161#ifdef USE_POSTGIS
2162 msPostGISLayerInfo *layerinfo;
2163 int order_test = 1;
2164
2165 assert(layer != NULL);
2166
2167 if (layer->debug) {
2168 msDebug("msPostGISLayerOpen called: %s\n", layer->data);
2169 }
2170
2171 if (layer->layerinfo) {
2172 if (layer->debug) {
2173 msDebug("msPostGISLayerOpen: Layer is already open!\n");
2174 }
2175 return MS_SUCCESS; /* already open */
2176 }
2177
2178 if (!layer->data) {
2179 msSetError(MS_QUERYERR, "Nothing specified in DATA statement.", "msPostGISLayerOpen()");
2180 return MS_FAILURE;
2181 }
2182
2183 /*
2184 ** Initialize the layerinfo
2185 **/
2186 layerinfo = msPostGISCreateLayerInfo();
2187
2188 if (((char*) &order_test)[0] == 1) {
2189 layerinfo->endian = LITTLE_ENDIAN;
2190 } else {
2191 layerinfo->endian = BIG_ENDIAN;
2192 }
2193
2194 /*
2195 ** Get a database connection from the pool.
2196 */
2197 layerinfo->pgconn = (PGconn *) msConnPoolRequest(layer);
2198
2199 /* No connection in the pool, so set one up. */
2200 if (!layerinfo->pgconn) {
2201 char *conn_decrypted;
2202 if (layer->debug) {
2203 msDebug("msPostGISLayerOpen: No connection in pool, creating a fresh one.\n");
2204 }
2205
2206 if (!layer->connection) {
2207 msSetError(MS_MISCERR, "Missing CONNECTION keyword.", "msPostGISLayerOpen()");
2208 return MS_FAILURE;
2209 }
2210
2211 /*
2212 ** Decrypt any encrypted token in connection string and attempt to connect.
2213 */
2214 conn_decrypted = msDecryptStringTokens(layer->map, layer->connection);
2215 if (conn_decrypted == NULL) {
2216 return MS_FAILURE; /* An error should already have been produced */
2217 }

Callers 1

msPostGISEscapeSQLParamFunction · 0.85

Calls 9

msDebugFunction · 0.85
msSetErrorFunction · 0.85
msPostGISCreateLayerInfoFunction · 0.85
msConnPoolRequestFunction · 0.85
msDecryptStringTokensFunction · 0.85
msFreeFunction · 0.85
msStrdupFunction · 0.85
msConnPoolRegisterFunction · 0.85
msPostGISRetrieveVersionFunction · 0.85

Tested by

no test coverage detected