startup.patch

application/octet-stream

Filename: startup.patch
Type: application/octet-stream
Part: 1
Message: [patch] for "psql : Allow processing of multiple -f (file) options "

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/bin/psql/startup.c 0 0
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
new file mode 100644
index b5664df..d5793f2
*** a/src/bin/psql/startup.c
--- b/src/bin/psql/startup.c
*************** PsqlSettings pset;

*** 42,48 ****
  #define SYSPSQLRC	"psqlrc"

  #define PSQLRC		"psqlrc.conf"

  #endif

! 

  /*

   * Structures to pass information between the option parsing routine

   * and the main function

--- 42,48 ----
  #define SYSPSQLRC	"psqlrc"

  #define PSQLRC		"psqlrc.conf"

  #endif

! #define NUM_FILES   50

  /*

   * Structures to pass information between the option parsing routine

   * and the main function

*************** struct adhoc_opts

*** 64,70 ****
  	char	   *username;

  	char	   *logfilename;

  	enum _actions action;

! 	char	   *action_string;

  	bool		no_readline;

  	bool		no_psqlrc;

  	bool		single_txn;

--- 64,70 ----
  	char	   *username;

  	char	   *logfilename;

  	enum _actions action;

! 	char	   *action_string[NUM_FILES];

  	bool		no_readline;

  	bool		no_psqlrc;

  	bool		single_txn;

*************** main(int argc, char *argv[])

*** 90,95 ****
--- 90,96 ----
  	char	   *password = NULL;

  	char	   *password_prompt = NULL;

  	bool		new_pass;

+ 	int  i = 0;

  

  	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("psql"));

  

*************** main(int argc, char *argv[])

*** 264,270 ****
  		if (!options.no_psqlrc)

  			process_psqlrc(argv[0]);

  

! 		successResult = process_file(options.action_string, options.single_txn, false);

  	}

  

  	/*

--- 265,274 ----
  		if (!options.no_psqlrc)

  			process_psqlrc(argv[0]);

  

! 		for (i=0; i< argc; i++)

! 		{

! 		successResult = process_file(options.action_string[i], options.single_txn,false);

! 		}

  	}

  

  	/*

*************** parse_psql_options(int argc, char *argv[
*** 377,382 ****
--- 381,387 ----
  	extern char *optarg;

  	extern int	optind;

  	int			c;

+ 	static int fileindex = 0;

  

  	memset(options, 0, sizeof *options);

  

*************** parse_psql_options(int argc, char *argv[
*** 392,402 ****
  				pset.popt.topt.format = PRINT_UNALIGNED;

  				break;

  			case 'c':

! 				options->action_string = optarg;

  				if (optarg[0] == '\\')

  				{

  					options->action = ACT_SINGLE_SLASH;

! 					options->action_string++;

  				}

  				else

  					options->action = ACT_SINGLE_QUERY;

--- 397,407 ----
  				pset.popt.topt.format = PRINT_UNALIGNED;

  				break;

  			case 'c':

! 				options->action_string[0] = optarg;

  				if (optarg[0] == '\\')

  				{

  					options->action = ACT_SINGLE_SLASH;

! 					options->action_string[0]++;

  				}

  				else

  					options->action = ACT_SINGLE_QUERY;

*************** parse_psql_options(int argc, char *argv[
*** 412,418 ****
  				break;

  			case 'f':

  				options->action = ACT_FILE;

! 				options->action_string = optarg;

  				break;

  			case 'F':

  				pset.popt.topt.fieldSep.separator = pg_strdup(optarg);

--- 417,423 ----
  				break;

  			case 'f':

  				options->action = ACT_FILE;

! 				options->action_string[fileindex++] = optarg;

  				break;

  			case 'F':

  				pset.popt.topt.fieldSep.separator = pg_strdup(optarg);