diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
new file mode 100644
index 662eab7..4eefe3b
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
*************** PSQL_EDITOR_LINENUMBER_ARG='--line '
*** 3332,3339 ****
       Both the system-wide <filename>psqlrc</filename> file and the user's
       <filename>~/.psqlrc</filename> file can be made version-specific
       by appending a dash and the <productname>PostgreSQL</productname>
!      release number, for example <filename>~/.psqlrc-&version;</filename>.
!      A matching version-specific file will be read in preference to a
       non-version-specific file.
      </para>
     </listitem>
--- 3332,3341 ----
       Both the system-wide <filename>psqlrc</filename> file and the user's
       <filename>~/.psqlrc</filename> file can be made version-specific
       by appending a dash and the <productname>PostgreSQL</productname>
!      major or minor release number, for example
!      <filename>~/.psqlrc-9.2</filename> or
!      <filename>~/.psqlrc-9.2.5</filename>.  The most specific
!      version-matching file will be read in preference to a
       non-version-specific file.
      </para>
     </listitem>
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
new file mode 100644
index 3c17eec..71829eb
*** a/src/bin/psql/startup.c
--- b/src/bin/psql/startup.c
*************** process_psqlrc(char *argv0)
*** 594,613 ****
  static void
  process_psqlrc_file(char *filename)
  {
! 	char	   *psqlrc;
  
  #if defined(WIN32) && (!defined(__MINGW32__))
  #define R_OK 4
  #endif
  
! 	psqlrc = pg_malloc(strlen(filename) + 1 + strlen(PG_VERSION) + 1);
! 	sprintf(psqlrc, "%s-%s", filename, PG_VERSION);
  
! 	if (access(psqlrc, R_OK) == 0)
! 		(void) process_file(psqlrc, false, false);
  	else if (access(filename, R_OK) == 0)
  		(void) process_file(filename, false, false);
! 	free(psqlrc);
  }
  
  
--- 594,620 ----
  static void
  process_psqlrc_file(char *filename)
  {
! 	char	   *psqlrc_minor, *psqlrc_major;
  
  #if defined(WIN32) && (!defined(__MINGW32__))
  #define R_OK 4
  #endif
  
! 	psqlrc_minor = pg_malloc(strlen(filename) + 1 + strlen(PG_VERSION) + 1);
! 	sprintf(psqlrc_minor, "%s-%s", filename, PG_VERSION);
! 	psqlrc_major = pg_malloc(strlen(filename) + 1 + strlen(PG_MAJORVERSION) + 1);
! 	sprintf(psqlrc_major, "%s-%s", filename, PG_MAJORVERSION);
  
! 	/* check for minor version first, then major, then no version */
! 	if (access(psqlrc_minor, R_OK) == 0)
! 		(void) process_file(psqlrc_minor, false, false);
! 	else if (access(psqlrc_major, R_OK) == 0)
! 		(void) process_file(psqlrc_major, false, false);
  	else if (access(filename, R_OK) == 0)
  		(void) process_file(filename, false, false);
! 
! 	free(psqlrc_minor);
! 	free(psqlrc_major);
  }
  
  
