*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.46 1998/06/15 19:28:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.47 1998/06/19 11:40:46 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim);
#endif
-static void CopyAttributeOut(FILE *fp, char *string, char *delim);
+static void CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array);
static int CountTuples(Relation relation);
extern FILE *Pfout,
{
string = (char *) (*fmgr_faddr(&out_functions[i]))
(value, elements[i], typmod[i]);
- CopyAttributeOut(fp, string, delim);
+ CopyAttributeOut(fp, string, delim, attr[i]->attnelems);
pfree(string);
}
else
{
loaded_oid = oidin(string);
if (loaded_oid < BootstrapObjectIdData)
- elog(ERROR, "COPY TEXT: Invalid Oid");
+ elog(ERROR, "COPY TEXT: Invalid Oid. line: %d", lineno);
}
}
for (i = 0; i < attr_count && !done; i++)
{
fread(&loaded_oid, sizeof(int32), 1, fp);
if (loaded_oid < BootstrapObjectIdData)
- elog(ERROR, "COPY BINARY: Invalid Oid");
+ elog(ERROR, "COPY BINARY: Invalid Oid line: %d", lineno);
}
fread(&null_ct, sizeof(int32), 1, fp);
if (null_ct > 0)
ptr += sizeof(int32);
break;
default:
- elog(ERROR, "COPY BINARY: impossible size!");
+ elog(ERROR, "COPY BINARY: impossible size! line: %d", lineno);
break;
}
}
case '.':
c = getc(fp);
if (c != '\n')
- elog(ERROR, "CopyReadAttribute - end of record marker corrupted");
+ elog(ERROR, "CopyReadAttribute - end of record marker corrupted. line: %d", lineno);
return (NULL);
break;
}
if (!done)
attribute[i++] = c;
if (i == EXT_ATTLEN - 1)
- elog(ERROR, "CopyReadAttribute - attribute length too long");
+ elog(ERROR, "CopyReadAttribute - attribute length too long. line: %d", lineno);
}
attribute[i] = '\0';
return (&attribute[0]);
}
static void
-CopyAttributeOut(FILE *fp, char *string, char *delim)
+CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array)
{
char c;
- int is_array = false;
- int len = strlen(string);
-
- /* XXX - This is a kludge, we should check the data type */
- if (len && (string[0] == '{') && (string[len - 1] == '}'))
- is_array = true;
for (; (c = *string) != '\0'; string++)
{