Re: Extract numeric filed in JSONB more effectively

Поиск
Список
Период
Сортировка
От Andy Fan
Тема Re: Extract numeric filed in JSONB more effectively
Дата
Msg-id CAKU4AWrGM5bK7wi4Y8bTYhKgh=A1fW=X00eC_jfk6_JXyaEURQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Extract numeric filed in JSONB more effectively  (Andy Fan <zhihui.fan1213@gmail.com>)
Ответы Re: Extract numeric filed in JSONB more effectively  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers

 jsonb_extract_xx_type just cares about the argtype, but 
'explain select xx'  will still access the const->constvalue.
const->constvalue is 0 which is set by makeNullConst currently, 
and it is ok for the current supported type. 

The exception is numeric data type, the constvalue can't be 0. 
so hack it with the below line.  maybe not good enough,  but I
have no better solution now. 

+                       Const   *target =  makeNullConst(fexpr->funcresulttype,
+                                                                                        -1,
+                                                                                        InvalidOid);
+                       /*
+                        * Since all the above functions are strict, we can't input
+                        * a NULL value.
+                        */
+                       target->constisnull = false;
+      
+                       Assert(target->constbyval || target->consttype == NUMERICOID);
+              
+                       /* Mock a valid datum for !constbyval type. */
+                       if (fexpr->funcresulttype == NUMERICOID)
+                               target->constvalue = DirectFunctionCall1(numeric_in, CStringGetDatum("0"));

--
Best Regards
Andy Fan
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: jian he
Дата:
Сообщение: Re: proposal: jsonb_populate_array
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Using defines for protocol characters