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

◆ add_raster_constraints()

static int add_raster_constraints ( const char *  schema,
const char *  table,
const char *  column,
int  regular_blocking,
int  max_extent,
STRINGBUFFER buffer 
)
static

Definition at line 1168 of file raster2pgsql.c.

1172 {
1173 char *sql = NULL;
1174 uint32_t len = 0;
1175
1176 char *_tmp = NULL;
1177 char *_schema = NULL;
1178 char *_table = NULL;
1179 char *_column = NULL;
1180
1181 assert(table != NULL);
1182 assert(column != NULL);
1183
1184 /* schema */
1185 if (schema != NULL) {
1186 _tmp = chartrim(schema, ".");
1187 _schema = chartrim(_tmp, "\"");
1188 rtdealloc(_tmp);
1189 _tmp = strreplace(_schema, "'", "''", NULL);
1190 rtdealloc(_schema);
1191 _schema = _tmp;
1192 }
1193
1194 /* table */
1195 _tmp = chartrim(table, "\"");
1196 _table = strreplace(_tmp, "'", "''", NULL);
1197 rtdealloc(_tmp);
1198
1199 /* column */
1200 _tmp = chartrim(column, "\"");
1201 _column = strreplace(_tmp, "'", "''", NULL);
1202 rtdealloc(_tmp);
1203
1204 len = strlen("SELECT AddRasterConstraints('','','',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE,FALSE);") + 1;
1205 if (_schema != NULL)
1206 len += strlen(_schema);
1207 len += strlen(_table);
1208 len += strlen(_column);
1209
1210 sql = rtalloc(sizeof(char) * len);
1211 if (sql == NULL) {
1212 rterror(_("add_raster_constraints: Could not allocate memory for AddRasterConstraints statement"));
1213 return 0;
1214 }
1215 sprintf(sql, "SELECT AddRasterConstraints('%s','%s','%s',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,%s,TRUE,TRUE,TRUE,TRUE,%s);",
1216 (_schema != NULL ? _schema : ""),
1217 _table,
1218 _column,
1219 (regular_blocking ? "TRUE" : "FALSE"),
1220 (max_extent ? "TRUE" : "FALSE")
1221 );
1222
1223 if (_schema != NULL)
1224 rtdealloc(_schema);
1225 rtdealloc(_table);
1226 rtdealloc(_column);
1227
1229
1230 return 1;
1231}
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 _(String)
Definition shpcommon.h:24

References _, append_sql_to_buffer(), buffer(), chartrim(), 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: