PostGIS 3.0.6dev-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 808 of file raster2pgsql.c.

811{
812 char *sql = NULL;
813 uint32_t len = 0;
814
815 assert(table != NULL);
816 assert(column != NULL);
817
818 len = strlen("COPY () FROM stdin;") + 1;
819 if (schema != NULL)
820 len += strlen(schema);
821 len += strlen(table);
822 len += strlen(column);
823 if (filename != NULL)
824 len += strlen(",") + strlen(file_column_name);
825
826 sql = rtalloc(sizeof(char) * len);
827 if (sql == NULL) {
828 rterror(_("copy_from: Could not allocate memory for COPY statement"));
829 return 0;
830 }
831 sprintf(sql, "COPY %s%s (%s%s%s) FROM stdin;",
832 (schema != NULL ? schema : ""),
833 table,
834 column,
835 (filename != NULL ? "," : ""),
836 (filename != NULL ? file_column_name : "")
837 );
838
840 sql = NULL;
841
842 return 1;
843}
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
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: