Please clarify about why $1 is not been replaced by 'colname' in delete_from_table2 function.
It has been replace with the string literal value ‘colname’, not a column reference identifier “colname”. You cannot use positional parameters to supply identifiers. Structure must be known at parse time.