Exception when executing with custom type parameter and at least one of its fields is null
See original GitHub issueHello everyone!
We have a stored procedure that takes custom type parameter on the input. If we set one of the fields of this type to null described exception happens.
Custom type example:
CREATE TYPE TItem AS
(
ID int,
ParentID smallint
);
SP example:
CREATE OR REPLACE FUNCTION spSaveItem(
_Item TItem
)
RETURNS void AS
$BODY$
BEGIN
-- any process code
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
Code example:
using (var cmd = new NpgsqlCommand("spSaveItem", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new NpgsqlParameter()
{
ParameterName = "_Item",
Value = new { ID = 5, ParentID = null },
DataTypeName = $"public.TItem",
});
cmd.ExecuteNonQuery();
}
Same thing happens if set ParentID to DBNull.Value.
Result is:
Exception message: 08P01: invalid frontend message type 1
Stack trace:
NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
NpgsqlDataReader.NextResult()
NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
NpgsqlCommand.ExecuteReader(CommandBehavior behavior)
Npgsql version: 4.1.3 PostgreSQL version: 12.1 Operating system: Ubuntu 12.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
IllegalArgumentException or NullPointerException for a ...
The NullPointerException is an exception thrown by the Java Virtual Machine when you try to execute code on null reference (Like toString()). ...
Read more >Should one check for null if he does not expect null?
Throw a custom exception that describes the problem on a higher level; this can be achieved either by throwing in the null check, ......
Read more >How to Handle the ArgumentNullException in C# | Rollbar
The ArgumentNullException occurs in C# when null arguments are passed to a method in that expects non-null values.
Read more >ArgumentNullException Class (System)
An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null but should never...
Read more >Understanding null safety
If you run this Dart program without null safety, it throws a NoSuchMethodError exception on the call to .length . The null value...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you guys, you’re doing really a tremendous job! Hope you’re well and safe!
@YohDeadfall modified the milestone to 4.1.4. Since github allows only one milestone to be select on an issue, I think it’s better to use it to express the latest stable patch release where the fix was merged (users can scan the issue to see other versions as well).