mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 10:30:33 +03:00 
			
		
		
		
	Correct constness of system attributes in heap.c & prerequisites.
This allows the compiler / linker to mark affected pages as read-only. There's a fair number of pre-requisite changes, to allow the const properly be propagated. Most of consts were already required for correctness anyway, just not represented on the type-level. Arguably we could be more aggressive in using consts in related code, but.. This requires using a few of the types underlying typedefs that removes pointers (e.g. const NameData *) as declaring the typedefed type constant doesn't have the same meaning (it makes the variable const, not what it points to). Discussion: https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de
This commit is contained in:
		| @@ -3135,7 +3135,7 @@ attnameAttNum(Relation rd, const char *attname, bool sysColOK) | ||||
| static int | ||||
| specialAttNum(const char *attname) | ||||
| { | ||||
| 	Form_pg_attribute sysatt; | ||||
| 	const FormData_pg_attribute *sysatt; | ||||
|  | ||||
| 	sysatt = SystemAttributeByName(attname, | ||||
| 								   true /* "oid" will be accepted */ ); | ||||
| @@ -3152,12 +3152,12 @@ specialAttNum(const char *attname) | ||||
|  *	heap_open()'ed.  Use the cache version get_atttype() | ||||
|  *	for access to non-opened relations. | ||||
|  */ | ||||
| Name | ||||
| const NameData * | ||||
| attnumAttName(Relation rd, int attid) | ||||
| { | ||||
| 	if (attid <= 0) | ||||
| 	{ | ||||
| 		Form_pg_attribute sysatt; | ||||
| 		const FormData_pg_attribute *sysatt; | ||||
|  | ||||
| 		sysatt = SystemAttributeDefinition(attid, rd->rd_rel->relhasoids); | ||||
| 		return &sysatt->attname; | ||||
| @@ -3179,7 +3179,7 @@ attnumTypeId(Relation rd, int attid) | ||||
| { | ||||
| 	if (attid <= 0) | ||||
| 	{ | ||||
| 		Form_pg_attribute sysatt; | ||||
| 		const FormData_pg_attribute *sysatt; | ||||
|  | ||||
| 		sysatt = SystemAttributeDefinition(attid, rd->rd_rel->relhasoids); | ||||
| 		return sysatt->atttypid; | ||||
|   | ||||
| @@ -2065,7 +2065,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) | ||||
| 		for (i = 0; i < index_form->indnatts; i++) | ||||
| 		{ | ||||
| 			int16		attnum = index_form->indkey.values[i]; | ||||
| 			Form_pg_attribute attform; | ||||
| 			const FormData_pg_attribute *attform; | ||||
| 			char	   *attname; | ||||
| 			Oid			defopclass; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user