mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Prevent psql from issuing BEGIN before ALTER SYSTEM when AUTOCOMMIT is off.
The autocommit-off mode works by issuing an implicit BEGIN just before any command that is not already in a transaction block and is not itself a BEGIN or other transaction-control command, nor a command that cannot be executed inside a transaction block. This commit prevents psql from issuing such an implicit BEGIN before ALTER SYSTEM because it's not allowed inside a transaction block. Backpatch to 9.4 where ALTER SYSTEM was added. Report by Feike Steenbergen
This commit is contained in:
		@@ -1524,6 +1524,23 @@ command_no_begin(const char *query)
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (wordlen == 5 && pg_strncasecmp(query, "alter", 5) == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							query += wordlen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							query = skip_white_space(query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							wordlen = 0;
 | 
				
			||||||
 | 
							while (isalpha((unsigned char) query[wordlen]))
 | 
				
			||||||
 | 
								wordlen += PQmblen(&query[wordlen], pset.encoding);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* ALTER SYSTEM isn't allowed in xacts */
 | 
				
			||||||
 | 
							if (wordlen == 6 && pg_strncasecmp(query, "system", 6) == 0)
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Note: these tests will match DROP SYSTEM and REINDEX TABLESPACE, which
 | 
						 * Note: these tests will match DROP SYSTEM and REINDEX TABLESPACE, which
 | 
				
			||||||
	 * aren't really valid commands so we don't care much. The other four
 | 
						 * aren't really valid commands so we don't care much. The other four
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user