{
JsonTypeArray,
JsonTypeObject,
- JsonTypeString
+ JsonTypeString,
+ JsonTypeNumber
} JsonType;
typedef enum
SpecOperatorname,
SpecDottedName,
SpecString,
+ SpecNumber,
SpecStringLiteral,
SpecIdentifier
} convSpecifier;
json_elt_type = JsonTypeObject;
else if (strcmp(paramtype, "string") == 0)
json_elt_type = JsonTypeString;
+ else if (strcmp(paramtype, "number") == 0)
+ json_elt_type = JsonTypeNumber;
else
/* XXX improve this; need to specify array index or param name */
elog(ERROR, "unexpected JSON element type %s",
}
}
+static void
+expand_jsonval_number(StringInfo buf, Datum jsonval)
+{
+ appendStringInfoString(buf, TextDatumGetCString(jsonval));
+}
+
/*
* Expand a json value as a string literal
*/
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("expected JSON string or object for %%s element \"%s\", got %s",
param, valtype)));
+ if (specifier == SpecNumber && json_elt_type != JsonTypeNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("expected JSON string or object for %%d element \"%s\", got %s",
+ param, valtype)));
switch (specifier)
{
expand_jsonval_strlit(buf, jsonval);
break;
+ case SpecNumber:
+ expand_jsonval_number(buf, jsonval);
+ break;
+
case SpecTypename:
expand_jsonval_typename(buf, jsonval);
break;
* O expand as an operator name
* L expand as a string literal (quote using single quotes)
* s expand as a simple string (no quoting)
+ * d expand as a simple number (no quoting)
*
* The element name may have an optional separator specification preceded
* by a colon. Its presence indicates that the element is expected to be
* 'O' -- expand as an operator name. Same as 'D', but the objname
* element is not quoted.
* 's' -- expand as a simple string; no quoting.
+ * 'd' -- expand as a number.
* 'T' -- expand as a typename, with ad-hoc rules
*/
switch (*cp)
case 's':
specifier = SpecString;
break;
+ case 'd':
+ specifier = SpecNumber;
+ break;
case 'L':
specifier = SpecStringLiteral;
break;
typeid = BOOLOID;
break;
case ObjTypeInteger:
- typeid = INT4OID;
+ typeid = INT8OID;
break;
case ObjTypeArray:
case ObjTypeObject:
values[i - 1] = CStringGetTextDatum(object->str_value);
break;
case ObjTypeInteger:
- values[i - 1] = Int32GetDatum(object->int_value);
+ values[i - 1] = Int64GetDatum(object->int_value);
break;
case ObjTypeArray:
{
case AT_SetStatistics:
{
Assert(IsA(subcmd->def, Integer));
- tmp = new_objtree_VA("ALTER COLUMN %{column}I SET STATISTICS %{statistics}s",
+ tmp = new_objtree_VA("ALTER COLUMN %{column}I SET STATISTICS %{statistics}d",
3, "type", ObjTypeString, "set statistics",
"column", ObjTypeString, subcmd->name,
"statistics", ObjTypeInteger, intVal((Value *) subcmd->def));