mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	psql: Support identity columns in sequence display
Where the footer for an owned serial sequence would say "Owned by", put something analogous for a sequence belonging to an identity column. Reported-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
This commit is contained in:
		@@ -2006,7 +2006,8 @@ describeOneTableDetails(const char *schemaname,
 | 
				
			|||||||
		/* Get the column that owns this sequence */
 | 
							/* Get the column that owns this sequence */
 | 
				
			||||||
		printfPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
 | 
							printfPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
 | 
				
			||||||
						  "\n   pg_catalog.quote_ident(relname) || '.' ||"
 | 
											  "\n   pg_catalog.quote_ident(relname) || '.' ||"
 | 
				
			||||||
						  "\n   pg_catalog.quote_ident(attname)"
 | 
											  "\n   pg_catalog.quote_ident(attname),"
 | 
				
			||||||
 | 
											  "\n   d.deptype"
 | 
				
			||||||
						  "\nFROM pg_catalog.pg_class c"
 | 
											  "\nFROM pg_catalog.pg_class c"
 | 
				
			||||||
					"\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
 | 
										"\nINNER JOIN pg_catalog.pg_depend d ON c.oid=d.refobjid"
 | 
				
			||||||
			 "\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
 | 
								 "\nINNER JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace"
 | 
				
			||||||
@@ -2016,7 +2017,7 @@ describeOneTableDetails(const char *schemaname,
 | 
				
			|||||||
			   "\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
 | 
								   "\nWHERE d.classid='pg_catalog.pg_class'::pg_catalog.regclass"
 | 
				
			||||||
			 "\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
 | 
								 "\n AND d.refclassid='pg_catalog.pg_class'::pg_catalog.regclass"
 | 
				
			||||||
						  "\n AND d.objid=%s"
 | 
											  "\n AND d.objid=%s"
 | 
				
			||||||
						  "\n AND d.deptype='a'",
 | 
											  "\n AND d.deptype IN ('a', 'i')",
 | 
				
			||||||
						  oid);
 | 
											  oid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		result = PSQLexec(buf.data);
 | 
							result = PSQLexec(buf.data);
 | 
				
			||||||
@@ -2024,9 +2025,19 @@ describeOneTableDetails(const char *schemaname,
 | 
				
			|||||||
			goto error_return;
 | 
								goto error_return;
 | 
				
			||||||
		else if (PQntuples(result) == 1)
 | 
							else if (PQntuples(result) == 1)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								switch (PQgetvalue(result, 0, 1)[0])
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									case 'a':
 | 
				
			||||||
					printfPQExpBuffer(&buf, _("Owned by: %s"),
 | 
										printfPQExpBuffer(&buf, _("Owned by: %s"),
 | 
				
			||||||
									  PQgetvalue(result, 0, 0));
 | 
														  PQgetvalue(result, 0, 0));
 | 
				
			||||||
					printTableAddFooter(&cont, buf.data);
 | 
										printTableAddFooter(&cont, buf.data);
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									case 'i':
 | 
				
			||||||
 | 
										printfPQExpBuffer(&buf, _("Sequence for identity column: %s"),
 | 
				
			||||||
 | 
														  PQgetvalue(result, 0, 0));
 | 
				
			||||||
 | 
										printTableAddFooter(&cont, buf.data);
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user