<?php
declare(strict_types=1);
$schema=static function(string $table)use($q){return ['columns'=>$q('SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME=? ORDER BY COLUMN_ID',[$table]),'indexes'=>$q('SELECT * FROM USER_INDEXES WHERE TABLE_NAME=? ORDER BY INDEX_NAME',[$table]),'index_columns'=>$q('SELECT * FROM USER_IND_COLUMNS WHERE TABLE_NAME=? ORDER BY INDEX_NAME,COLUMN_POSITION',[$table]),'constraints'=>$q('SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME=? ORDER BY CONSTRAINT_NAME',[$table]),'constraint_columns'=>$q('SELECT * FROM USER_CONS_COLUMNS WHERE TABLE_NAME=? ORDER BY CONSTRAINT_NAME,POSITION',[$table]),'triggers'=>$q('SELECT * FROM USER_TRIGGERS WHERE TABLE_NAME=? ORDER BY TRIGGER_NAME',[$table]),'DDL'=>$q("SELECT DBMS_METADATA.GET_DDL('TABLE',?,'AIZHCT_APP') ddl FROM DUAL",[$table])];};
$check=static function($ok,$why){if(!$ok)throw new RuntimeException($why);};
function normalizeSchemaNumericMetadata(array $meta):array{
 $allowed=['columns'=>['data_length','data_scale','column_id','char_col_decl_length','char_length','default_length'],'indexes'=>['initial_extent','next_extent','min_extents'],'index_columns'=>['column_position','column_length','char_length'],'constraint_columns'=>['position']];
 foreach($allowed as $group=>$fields)if(isset($meta[$group]))foreach($meta[$group] as &$row)foreach($fields as $field)if(isset($row[$field])&&is_float($row[$field])){if(!is_finite($row[$field])||floor($row[$field])!==$row[$field]||$row[$field]<0||$row[$field]>1000000)throw new RuntimeException('Only proven small integral schema metadata '.$group.'.'.$field);$row[$field]=(int)$row[$field];}unset($row);
 return $meta;
}
