X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fpsql-reader.c;h=85e777a991b9218bfbf2c5f17555a9972093bd5e;hb=537fdeb3702c011e05d7826a8d556a7beeba2605;hp=a54b9f8b3888c58320623ea1d53086bc8650a155;hpb=a1efcf97ca2f75f4be6a0389ff2372c03ed2d4e1;p=pspp-builds.git diff --git a/src/data/psql-reader.c b/src/data/psql-reader.c index a54b9f8b..85e777a9 100644 --- a/src/data/psql-reader.c +++ b/src/data/psql-reader.c @@ -288,10 +288,22 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) /* Create the dictionary and populate it */ *dict = r->dict = dict_create (); + { + const int enc = PQclientEncoding (r->conn); + + /* According to section 22.2 of the Postgresql manual + a value of zero (SQL_ASCII) indicates + "a declaration of ignorance about the encoding". + Accordingly, we don't set the dictionary's encoding + if we find this value. + */ + if ( enc != 0 ) + dict_set_encoding (r->dict, pg_encoding_to_char (enc)); + } + /* select count (*) from (select * from medium) stupid_sql_standard; */ - ds_init_cstr (&query, "BEGIN READ ONLY ISOLATION LEVEL SERIALIZABLE; " "DECLARE pspp BINARY CURSOR FOR "); @@ -440,6 +452,10 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) break; } + if ( width == 0 && fmt_is_string (fmt.type)) + fmt.w = width = MAX_SHORT_STRING; + + var = create_var (r, &fmt, width, PQfname (qres, i), i); if ( type == NUMERICOID && n_tuples > 0) {