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

◆ copy_from()

static int copy_from ( const char *  schema,
const char *  table,
const char *  column,
const char *  filename,
const char *  file_column_name,
STRINGBUFFER buffer 
)
static

Definition at line 820 of file raster2pgsql.c.

823{
824 char *sql = NULL;
825 uint32_t len = 0;
826
827 assert(table != NULL);
828 assert(column != NULL);
829
830 len = strlen("COPY () FROM stdin;") + 1;
831 if (schema != NULL)
832 len += strlen(schema);
833 len += strlen(table);
834 len += strlen(column);
835 if (filename != NULL)
836 len += strlen(",") + strlen(file_column_name);
837
838 sql = rtalloc(sizeof(char) * len);
839 if (sql == NULL) {
840 rterror(_("copy_from: Could not allocate memory for COPY statement"));
841 return 0;
842 }
843 sprintf(sql, "COPY %s%s (%s%s%s) FROM stdin;",
844 (schema != NULL ? schema : ""),
845 table,
846 column,
847 (filename != NULL ? "," : ""),
848 (filename != NULL ? file_column_name : "")
849 );
850
852 sql = NULL;
853
854 return 1;
855}
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
Datum buffer(PG_FUNCTION_ARGS)
static int append_sql_to_buffer(STRINGBUFFER *buffer, const char *str)
#define _(String)
Definition shpcommon.h:24

References _, append_sql_to_buffer(), buffer(), rtalloc(), and rterror().

Referenced by insert_records().

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