+static int
+parse_get_psql (struct lexer *lexer, struct dataset *ds)
+{
+ struct psql_read_info psql;
+ psql.allow_clear = false;
+ psql.conninfo = NULL;
+ psql.str_width = -1;
+ psql.bsize = -1;
+ ds_init_empty (&psql.sql);
+
+ lex_force_match (lexer, '/');
+
+ if (!lex_force_match_id (lexer, "CONNECT"))
+ goto error;
+
+ lex_force_match (lexer, '=');
+
+ if (!lex_force_string (lexer))
+ goto error;
+
+ psql.conninfo = xstrdup (ds_cstr (lex_tokstr (lexer)));
+
+ lex_get (lexer);
+
+ while (lex_match (lexer, '/') )
+ {
+ if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
+ {
+ lex_match (lexer, '=');
+ psql.str_width = lex_integer (lexer);
+ lex_get (lexer);
+ }
+ else if ( lex_match_id (lexer, "BSIZE"))
+ {
+ lex_match (lexer, '=');
+ psql.bsize = lex_integer (lexer);
+ lex_get (lexer);
+ }
+ else if ( lex_match_id (lexer, "UNENCRYPTED"))
+ {
+ psql.allow_clear = true;
+ }
+ else if (lex_match_id (lexer, "SQL"))
+ {
+ lex_match (lexer, '=');
+ if ( ! lex_force_string (lexer) )
+ goto error;
+
+ ds_put_substring (&psql.sql, lex_tokstr (lexer)->ss);
+ lex_get (lexer);
+ }
+ }
+ {
+ struct dictionary *dict = NULL;
+ struct casereader *reader = psql_open_reader (&psql, &dict);
+
+ if ( reader )
+ proc_set_active_file (ds, reader, dict);
+ }
+
+ ds_destroy (&psql.sql);
+ free (psql.conninfo);
+
+ return CMD_SUCCESS;
+
+ error:
+
+ ds_destroy (&psql.sql);
+ free (psql.conninfo);
+
+ return CMD_FAILURE;
+}