/* PSPP - a program for statistical analysis.
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <libpq-fe.h>
+/* Default width of string variables. */
+#define PSQL_DEFAULT_WIDTH 8
+
/* These macros must be the same as in catalog/pg_types.h from the postgres source */
#define BOOLOID 16
#define BYTEAOID 17
}
}
- r->postgres_epoch =
- calendar_gregorian_to_offset (2000, 1, 1, NULL, NULL);
+ r->postgres_epoch = calendar_gregorian_to_offset (2000, 1, 1, NULL);
/* Create the dictionary and populate it */
if ( n_tuples > 0 )
length = PQgetlength (qres, 0, i);
else
- length = MAX_SHORT_STRING;
+ length = PSQL_DEFAULT_WIDTH;
switch (type)
{
case BPCHAROID:
fmt.type = FMT_A;
width = (info->str_width == -1) ?
- ROUND_UP (length, MAX_SHORT_STRING) : info->str_width;
+ ROUND_UP (length, PSQL_DEFAULT_WIDTH) : info->str_width;
fmt.w = width;
fmt.d = 0;
break;
case BYTEAOID:
fmt.type = FMT_AHEX;
- width = length > 0 ? length : MAX_SHORT_STRING;
+ width = length > 0 ? length : PSQL_DEFAULT_WIDTH;
fmt.w = width * 2;
fmt.d = 0;
break;
default:
msg (MW, _("Unsupported OID %d. SYSMIS values will be inserted."), type);
fmt.type = FMT_A;
- width = length > 0 ? length : MAX_SHORT_STRING;
+ width = length > 0 ? length : PSQL_DEFAULT_WIDTH;
fmt.w = width ;
fmt.d = 0;
break;
}
if ( width == 0 && fmt_is_string (fmt.type))
- fmt.w = width = MAX_SHORT_STRING;
+ fmt.w = width = PSQL_DEFAULT_WIDTH;
var = create_var (r, &fmt, width, PQfname (qres, i), i);
case VARCHAROID:
case BPCHAROID:
case BYTEAOID:
- memcpy (value_str_rw (val, var_width), (char *) vptr,
+ memcpy (value_str_rw (val, var_width), vptr,
MIN (length, var_width));
break;