PostGIS 3.7.0dev-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 1234 of file raster2pgsql.c.

1239 {
1240 char *sql = NULL;
1241 uint32_t len = 0;
1242
1243 char *_tmp = NULL;
1244
1245 char *_ovschema = NULL;
1246 char *_ovtable = NULL;
1247 char *_ovcolumn = NULL;
1248
1249 char *_schema = NULL;
1250 char *_table = NULL;
1251 char *_column = NULL;
1252
1253 assert(ovtable != NULL);
1254 assert(ovcolumn != NULL);
1255 assert(table != NULL);
1256 assert(column != NULL);
1257 assert(factor >= MINOVFACTOR && factor <= MAXOVFACTOR);
1258
1259 /* overview schema */
1260 if (ovschema != NULL) {
1261 _tmp = chartrim(ovschema, ".");
1262 _ovschema = chartrim(_tmp, "\"");
1263 rtdealloc(_tmp);
1264 _tmp = strreplace(_ovschema, "'", "''", NULL);
1265 rtdealloc(_ovschema);
1266 _ovschema = _tmp;
1267 }
1268
1269 /* overview table */
1270 _tmp = chartrim(ovtable, "\"");
1271 _ovtable = strreplace(_tmp, "'", "''", NULL);
1272 rtdealloc(_tmp);
1273
1274 /* overview column*/
1275 _tmp = chartrim(ovcolumn, "\"");
1276 _ovcolumn = strreplace(_tmp, "'", "''", NULL);
1277 rtdealloc(_tmp);
1278
1279 /* schema */
1280 if (schema != NULL) {
1281 _tmp = chartrim(schema, ".");
1282 _schema = chartrim(_tmp, "\"");
1283 rtdealloc(_tmp);
1284 _tmp = strreplace(_schema, "'", "''", NULL);
1285 rtdealloc(_schema);
1286 _schema = _tmp;
1287 }
1288
1289 /* table */
1290 _tmp = chartrim(table, "\"");
1291 _table = strreplace(_tmp, "'", "''", NULL);
1292 rtdealloc(_tmp);
1293
1294 /* column */
1295 _tmp = chartrim(column, "\"");
1296 _column = strreplace(_tmp, "'", "''", NULL);
1297 rtdealloc(_tmp);
1298
1299 len = strlen("SELECT AddOverviewConstraints('','','','','','',);") + 5;
1300 if (_ovschema != NULL)
1301 len += strlen(_ovschema);
1302 len += strlen(_ovtable);
1303 len += strlen(_ovcolumn);
1304 if (_schema != NULL)
1305 len += strlen(_schema);
1306 len += strlen(_table);
1307 len += strlen(_column);
1308
1309 sql = rtalloc(sizeof(char) * len);
1310 if (sql == NULL) {
1311 rterror(_("add_overview_constraints: Could not allocate memory for AddOverviewConstraints statement"));
1312 return 0;
1313 }
1314 sprintf(sql, "SELECT AddOverviewConstraints('%s','%s','%s','%s','%s','%s',%d);",
1315 (_ovschema != NULL ? _ovschema : ""),
1316 _ovtable,
1317 _ovcolumn,
1318 (_schema != NULL ? _schema : ""),
1319 _table,
1320 _column,
1321 factor
1322 );
1323
1324 if (_ovschema != NULL)
1325 rtdealloc(_ovschema);
1326 rtdealloc(_ovtable);
1327 rtdealloc(_ovcolumn);
1328
1329 if (_schema != NULL)
1330 rtdealloc(_schema);
1331 rtdealloc(_table);
1332 rtdealloc(_column);
1333
1335
1336 return 1;
1337}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
void rtdealloc(void *mem)
Definition rt_context.c:206
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: