Zainab-Saad commented on code in PR #905:
URL: https://github.com/apache/age/pull/905#discussion_r1189107335


##########
regress/expected/agtype.out:
##########
@@ -2138,6 +2142,50 @@ SELECT agtype_to_int8(agtype_in('false'));
               0
 (1 row)
 
+--
+-- Test boolean to integer cast
+--
+SELECT agtype_to_int4(agtype_in('true'));
+ agtype_to_int4 
+----------------
+              1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('false'));
+ agtype_to_int4 
+----------------
+              0
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('null'));
+ agtype_to_int4 
+----------------
+               
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1'));
+ agtype_to_int4 
+----------------
+              1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1.45'));
+ agtype_to_int4 
+----------------
+              1
+(1 row)
+
+SELECT agtype_to_int4(agtype_in('1.444::numeric'));
+ agtype_to_int4 
+----------------
+              1
+(1 row)
+
+-- These should all fail
+SELECT agtype_to_int4(agtype_in('"string"'));
+ERROR:  invalid input syntax for integer: "string"
+SELECT agtype_to_int4(agtype_in('[1, 2, 3]'));
+ERROR:  cannot cast agtype array to type int

Review Comment:
   @jrgemignani I have verified, the crash is not because of my changes but 
existed before. The server crashes for agtype_to_int2, agtype_to_int4, 
agtype_to_int8 for this input. 
   I am looking for a solution to fix this, but I believe that dealing this bug 
here would make this PR very cluttered since there are many functions that need 
changes.
   I can resolve this bug in another PR if that's fine to deal with these edge 
cases there. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to