PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ add_overview_constraints()

static int add_overview_constraints ( const char *  ovschema,
const char *  ovtable,
const char *  ovcolumn,
const char *  schema,
const char *  table,
const char *  column,
const int  factor,
STRINGBUFFER buffer 
)
static

Definition at line 1222 of file raster2pgsql.c.

1227 {
1228 char *sql = NULL;
1229 uint32_t len = 0;
1230
1231 char *_tmp = NULL;
1232
1233 char *_ovschema = NULL;
1234 char *_ovtable = NULL;
1235 char *_ovcolumn = NULL;
1236
1237 char *_schema = NULL;
1238 char *_table = NULL;
1239 char *_column = NULL;
1240
1241 assert(ovtable != NULL);
1242 assert(ovcolumn != NULL);
1243 assert(table != NULL);
1244 assert(column != NULL);
1245 assert(factor >= MINOVFACTOR && factor <= MAXOVFACTOR);
1246
1247 /* overview schema */
1248 if (ovschema != NULL) {
1249 _tmp = chartrim(ovschema, ".");
1250 _ovschema = chartrim(_tmp, "\"");
1251 rtdealloc(_tmp);
1252 _tmp = strreplace(_ovschema, "'", "''", NULL);
1253 rtdealloc(_ovschema);
1254 _ovschema = _tmp;
1255 }
1256
1257 /* overview table */
1258 _tmp = chartrim(ovtable, "\"");
1259 _ovtable = strreplace(_tmp, "'", "''", NULL);
1260 rtdealloc(_tmp);
1261
1262 /* overview column*/
1263 _tmp = chartrim(ovcolumn, "\"");
1264 _ovcolumn = strreplace(_tmp, "'", "''", NULL);
1265 rtdealloc(_tmp);
1266
1267 /* schema */
1268 if (schema != NULL) {
1269 _tmp = chartrim(schema, ".");
1270 _schema = chartrim(_tmp, "\"");
1271 rtdealloc(_tmp);
1272 _tmp = strreplace(_schema, "'", "''", NULL);
1273 rtdealloc(_schema);
1274 _schema = _tmp;
1275 }
1276
1277 /* table */
1278 _tmp = chartrim(table, "\"");
1279 _table = strreplace(_tmp, "'", "''", NULL);
1280 rtdealloc(_tmp);
1281
1282 /* column */
1283 _tmp = chartrim(column, "\"");
1284 _column = strreplace(_tmp, "'", "''", NULL);
1285 rtdealloc(_tmp);
1286
1287 len = strlen("SELECT AddOverviewConstraints('','','','','','',);") + 5;
1288 if (_ovschema != NULL)
1289 len += strlen(_ovschema);
1290 len += strlen(_ovtable);
1291 len += strlen(_ovcolumn);
1292 if (_schema != NULL)
1293 len += strlen(_schema);
1294 len += strlen(_table);
1295 len += strlen(_column);
1296
1297 sql = rtalloc(sizeof(char) * len);
1298 if (sql == NULL) {
1299 rterror(_("add_overview_constraints: Could not allocate memory for AddOverviewConstraints statement"));
1300 return 0;
1301 }
1302 sprintf(sql, "SELECT AddOverviewConstraints('%s','%s','%s','%s','%s','%s',%d);",
1303 (_ovschema != NULL ? _ovschema : ""),
1304 _ovtable,
1305 _ovcolumn,
1306 (_schema != NULL ? _schema : ""),
1307 _table,
1308 _column,
1309 factor
1310 );
1311
1312 if (_ovschema != NULL)
1313 rtdealloc(_ovschema);
1314 rtdealloc(_ovtable);
1315 rtdealloc(_ovcolumn);
1316
1317 if (_schema != NULL)
1318 rtdealloc(_schema);
1319 rtdealloc(_table);
1320 rtdealloc(_column);
1321
1323
1324 return 1;
1325}
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:171
void rtdealloc(void *mem)
Definition rt_context.c:186
Datum buffer(PG_FUNCTION_ARGS)
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
static char * strreplace(const char *str, const char *oldstr, const char *newstr, int *count)
static char * chartrim(const char *input, char *remove)
#define MAXOVFACTOR
#define MINOVFACTOR
#define _(String)
Definition shpcommon.h:24

References _, append_sql_to_buffer(), buffer(), chartrim(), MAXOVFACTOR, MINOVFACTOR, rtalloc(), rtdealloc(), rterror(), and strreplace().

Referenced by process_rasters().

Here is the call graph for this function:
Here is the caller graph for this function: