mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Fix dumping role comments when using --no-role-passwords
Commit 9a83d56b38c added support for allowing pg_dumpall to dump roles without including passwords, which accidentally made dumps omit COMMENTs on roles. This fixes it by using pg_authid to get the comment. Backpatch to all supported versions. Patch simultaneously written independently by Álvaro and myself. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Author: Daniel Gustafsson <daniel@yesql.se> Reported-by: Bartosz Chroł <bartosz.chrol@handen.pl> Discussion: https://postgr.es/m/AS8P194MB1271CDA0ADCA7B75FCD8E767F7332@AS8P194MB1271.EURP194.PROD.OUTLOOK.COM Discussion: https://postgr.es/m/CAEP4nAz9V4H41_4ESJd1Gf0v%3DdevkqO1%3Dpo91jUw-GJSx8Hxqg%40mail.gmail.com Backpatch-through: v12
This commit is contained in:
		
							parent
							
								
									485f0aa859
								
							
						
					
					
						commit
						7e65ad197f
					
				| @ -769,28 +769,31 @@ dumpRoles(PGconn *conn) | |||||||
| 				i_is_current_user; | 				i_is_current_user; | ||||||
| 	int			i; | 	int			i; | ||||||
| 
 | 
 | ||||||
| 	/* note: rolconfig is dumped later */ | 	/*
 | ||||||
|  | 	 * Notes: rolconfig is dumped later, and pg_authid must be used for | ||||||
|  | 	 * extracting rolcomment regardless of role_catalog. | ||||||
|  | 	 */ | ||||||
| 	if (server_version >= 90600) | 	if (server_version >= 90600) | ||||||
| 		printfPQExpBuffer(buf, | 		printfPQExpBuffer(buf, | ||||||
| 						  "SELECT oid, rolname, rolsuper, rolinherit, " | 						  "SELECT oid, rolname, rolsuper, rolinherit, " | ||||||
| 						  "rolcreaterole, rolcreatedb, " | 						  "rolcreaterole, rolcreatedb, " | ||||||
| 						  "rolcanlogin, rolconnlimit, rolpassword, " | 						  "rolcanlogin, rolconnlimit, rolpassword, " | ||||||
| 						  "rolvaliduntil, rolreplication, rolbypassrls, " | 						  "rolvaliduntil, rolreplication, rolbypassrls, " | ||||||
| 						  "pg_catalog.shobj_description(oid, '%s') as rolcomment, " | 						  "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, " | ||||||
| 						  "rolname = current_user AS is_current_user " | 						  "rolname = current_user AS is_current_user " | ||||||
| 						  "FROM %s " | 						  "FROM %s " | ||||||
| 						  "WHERE rolname !~ '^pg_' " | 						  "WHERE rolname !~ '^pg_' " | ||||||
| 						  "ORDER BY 2", role_catalog, role_catalog); | 						  "ORDER BY 2", role_catalog); | ||||||
| 	else if (server_version >= 90500) | 	else if (server_version >= 90500) | ||||||
| 		printfPQExpBuffer(buf, | 		printfPQExpBuffer(buf, | ||||||
| 						  "SELECT oid, rolname, rolsuper, rolinherit, " | 						  "SELECT oid, rolname, rolsuper, rolinherit, " | ||||||
| 						  "rolcreaterole, rolcreatedb, " | 						  "rolcreaterole, rolcreatedb, " | ||||||
| 						  "rolcanlogin, rolconnlimit, rolpassword, " | 						  "rolcanlogin, rolconnlimit, rolpassword, " | ||||||
| 						  "rolvaliduntil, rolreplication, rolbypassrls, " | 						  "rolvaliduntil, rolreplication, rolbypassrls, " | ||||||
| 						  "pg_catalog.shobj_description(oid, '%s') as rolcomment, " | 						  "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, " | ||||||
| 						  "rolname = current_user AS is_current_user " | 						  "rolname = current_user AS is_current_user " | ||||||
| 						  "FROM %s " | 						  "FROM %s " | ||||||
| 						  "ORDER BY 2", role_catalog, role_catalog); | 						  "ORDER BY 2", role_catalog); | ||||||
| 	else | 	else | ||||||
| 		printfPQExpBuffer(buf, | 		printfPQExpBuffer(buf, | ||||||
| 						  "SELECT oid, rolname, rolsuper, rolinherit, " | 						  "SELECT oid, rolname, rolsuper, rolinherit, " | ||||||
| @ -798,10 +801,10 @@ dumpRoles(PGconn *conn) | |||||||
| 						  "rolcanlogin, rolconnlimit, rolpassword, " | 						  "rolcanlogin, rolconnlimit, rolpassword, " | ||||||
| 						  "rolvaliduntil, rolreplication, " | 						  "rolvaliduntil, rolreplication, " | ||||||
| 						  "false as rolbypassrls, " | 						  "false as rolbypassrls, " | ||||||
| 						  "pg_catalog.shobj_description(oid, '%s') as rolcomment, " | 						  "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, " | ||||||
| 						  "rolname = current_user AS is_current_user " | 						  "rolname = current_user AS is_current_user " | ||||||
| 						  "FROM %s " | 						  "FROM %s " | ||||||
| 						  "ORDER BY 2", role_catalog, role_catalog); | 						  "ORDER BY 2", role_catalog); | ||||||
| 
 | 
 | ||||||
| 	res = executeQuery(conn, buf->data); | 	res = executeQuery(conn, buf->data); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user