iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >怎么实现PostgreSQL中的类型转换
  • 147
分享到

怎么实现PostgreSQL中的类型转换

2024-04-02 19:04:59 147人浏览 独家记忆
摘要

本篇内容主要讲解“怎么实现postgresql中的类型转换”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么实现Postgresql中的类型转换”吧!解析表达式

本篇内容主要讲解“怎么实现postgresql中的类型转换”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么实现Postgresql中的类型转换”吧!

解析表达式,涉及不同数据类型时:
1.如有相应类型的Operator定义(pg_operator),则尝试进行类型转换,否则报错;
2.如有相应类型的转换规则,转换为目标类型后解析,否则报错.

一、数据结构

Form_pg_operator
pg_operator中的定义,代码会其中的定义转换为FORMData_pg_operator结构体


CATALOG(pg_operator,2617,OperatorRelationId)
{
  Oid     oid;      
  
  NameData  oprname;
  
  Oid     oprnamespace BKI_DEFAULT(PGNSP);
  
  Oid     oprowner BKI_DEFAULT(PGUID);
  
  char    oprkind BKI_DEFAULT(b);
  
  bool    oprcanmerge BKI_DEFAULT(f);
  
  bool    oprcanhash BKI_DEFAULT(f);
  
  Oid     oprleft BKI_LOOKUP(pg_type);
  
  Oid     oprright BKI_LOOKUP(pg_type);
  
  Oid     oprresult BKI_LOOKUP(pg_type);
  
  Oid     oprcom BKI_DEFAULT(0) BKI_LOOKUP(pg_operator);
  
  Oid     oprnegate BKI_DEFAULT(0) BKI_LOOKUP(pg_operator);
  
  regproc   oprcode BKI_LOOKUP(pg_proc);
  
  regproc   oprrest BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
  
  regproc   oprjoin BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
} FormData_pg_operator;

typedef FormData_pg_operator *Form_pg_operator;

二、源码解读

coerce_type函数实现具体的类型转换.


node *
coerce_type(ParseState *pstate, Node *node,
      Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod,
      CoercionContext ccontext, CoercionForm cformat, int location)
{
  Node     *result;//结果Node
  CoercionPathType pathtype;
  Oid     funcId;
  if (targetTypeId == inputTypeId ||
    node == NULL)
  {
    
    //不需要转换
    return node;
  }
  if (targetTypeId == ANYOID ||
    targetTypeId == ANYELEMENTOID ||
    targetTypeId == ANYNONARRAYOID)
  {
    
    //目标类型可以为任意类型(ANYXXX)
    return node;
  }
  if (targetTypeId == ANYARRAYOID ||
    targetTypeId == ANYENUMOID ||
    targetTypeId == ANYRANGEOID)
  {
    
    if (inputTypeId != UNKNOWNOID)
    {
      //获取基本类型
      Oid     baseTypeId = getBaseType(inputTypeId);
      if (baseTypeId != inputTypeId)
      {
        RelabelType *r = makeRelabelType((Expr *) node,
                         baseTypeId, -1,
                         InvalidOid,
                         cformat);
        r->location = location;
        return (Node *) r;
      }
      
      return node;
    }
  }
  if (inputTypeId == UNKNOWNOID && IsA(node, Const))
  {
    //---------------- 输入类型为unknown并且是常量
    
    Const    *con = (Const *) node;//常量
    Const    *newcon = makeNode(Const);//转换后逇常量
    Oid     baseTypeId;//基本类型Oid
    int32   baseTypeMod;//基本typmode
    int32   inputTypeMod;//输入typmode
    Type    baseType;//基本类型
    ParseCallbackState pcbstate;//解析回调函数
    
    baseTypeMod = targetTypeMod;
    baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
    
    if (baseTypeId == INTERVALOID)
      inputTypeMod = baseTypeMod;
    else
      inputTypeMod = -1;
    baseType = typeidType(baseTypeId);
    //构造输出常量Const
    newcon->consttype = baseTypeId;
    newcon->consttypmod = inputTypeMod;
    newcon->constcollid = typeTypeCollation(baseType);
    newcon->constlen = typeLen(baseType);
    newcon->constbyval = typeByVal(baseType);
    newcon->constisnull = con->constisnull;
    
    //使用原始位置
    newcon->location = con->location;
    
    //如果报错,则指向该常量文本
    setup_parser_errposition_callback(&pcbstate, pstate, con->location);
    
    if (!con->constisnull)
      newcon->constvalue = stringTypeDatum(baseType,
                         DatumGetCString(con->constvalue),
                         inputTypeMod);
    else
      newcon->constvalue = stringTypeDatum(baseType,
                         NULL,
                         inputTypeMod);
    
    //如为可变长度值,则强制其为非扩展格式.
    if (!con->constisnull && newcon->constlen == -1)
      newcon->constvalue =
        PointerGetDatum(PG_DETOAST_DATUM(newcon->constvalue));
#ifdef RANDOMIZE_ALLOCATED_MEMORY
    
    if (!con->constisnull && !newcon->constbyval)
    {
      Datum   val2;
      val2 = stringTypeDatum(baseType,
                   DatumGetCString(con->constvalue),
                   inputTypeMod);
      if (newcon->constlen == -1)
        val2 = PointerGetDatum(PG_DETOAST_DATUM(val2));
      if (!datumIsEqual(newcon->constvalue, val2, false, newcon->constlen))
        elog(WARNING, "type %s has unstable input conversion for \"%s\"",
           typeTypeName(baseType), DatumGetCString(con->constvalue));
    }
#endif
    cancel_parser_errposition_callback(&pcbstate);
    //结果Node
    result = (Node *) newcon;
    
    if (baseTypeId != targetTypeId)
      result = coerce_to_domain(result,
                    baseTypeId, baseTypeMod,
                    targetTypeId,
                    ccontext, cformat, location,
                    false);
    ReleaseSysCache(baseType);
    //返回
    return result;
  }
  if (IsA(node, Param) &&
    pstate != NULL && pstate->p_coerce_param_hook != NULL)
  {
    
    result = pstate->p_coerce_param_hook(pstate,
                       (Param *) node,
                       targetTypeId,
                       targetTypeMod,
                       location);
    if (result)
      return result;
  }
  if (IsA(node, CollateExpr))
  {
    
    CollateExpr *coll = (CollateExpr *) node;
    CollateExpr *newcoll = makeNode(CollateExpr);
    newcoll->arg = (Expr *)
      coerce_type(pstate, (Node *) coll->arg,
            inputTypeId, targetTypeId, targetTypeMod,
            ccontext, cformat, location);
    newcoll->collOid = coll->collOid;
    newcoll->location = coll->location;
    return (Node *) newcoll;
  }
  pathtype = find_coercion_pathway(targetTypeId, inputTypeId, ccontext,
                   &funcId);
  if (pathtype != COERCION_PATH_NONE)
  {
    if (pathtype != COERCION_PATH_RELABELTYPE)
    {
      
      Oid     baseTypeId;
      int32   baseTypeMod;
      baseTypeMod = targetTypeMod;
      baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
      result = build_coercion_expression(node, pathtype, funcId,
                         baseTypeId, baseTypeMod,
                         ccontext, cformat, location);
      
      if (targetTypeId != baseTypeId)
        result = coerce_to_domain(result, baseTypeId, baseTypeMod,
                      targetTypeId,
                      ccontext, cformat, location,
                      true);
    }
    else
    {
      
      result = coerce_to_domain(node, InvalidOid, -1, targetTypeId,
                    ccontext, cformat, location,
                    false);
      if (result == node)
      {
        
        RelabelType *r = makeRelabelType((Expr *) result,
                         targetTypeId, -1,
                         InvalidOid,
                         cformat);
        r->location = location;
        result = (Node *) r;
      }
    }
    return result;
  }
  if (inputTypeId == RECORDOID &&
    ISCOMPLEX(targetTypeId))
  {
    
    return coerce_record_to_complex(pstate, node, targetTypeId,
                    ccontext, cformat, location);
  }
  if (targetTypeId == RECORDOID &&
    ISCOMPLEX(inputTypeId))
  {
    
    
    return node;
  }
#ifdef NOT_USED
  if (inputTypeId == RECORDARRAYOID &&
    is_complex_array(targetTypeId))
  {
    
    
  }
#endif
  if (targetTypeId == RECORDARRAYOID &&
    is_complex_array(inputTypeId))
  {
    
    
    return node;
  }
  if (typeInheritsFrom(inputTypeId, targetTypeId)
    || typeIsOfTypedTable(inputTypeId, targetTypeId))
  {
    
    Oid     baseTypeId = getBaseType(inputTypeId);
    ConvertRowtypeExpr *r = makeNode(ConvertRowtypeExpr);
    if (baseTypeId != inputTypeId)
    {
      RelabelType *rt = makeRelabelType((Expr *) node,
                        baseTypeId, -1,
                        InvalidOid,
                        COERCE_IMPLICIT_CAST);
      rt->location = location;
      node = (Node *) rt;
    }
    r->arg = (Expr *) node;
    r->resulttype = targetTypeId;
    r->convertformat = cformat;
    r->location = location;
    return (Node *) r;
  }
  
  elog(ERROR, "failed to find conversion function from %s to %s",
     format_type_be(inputTypeId), format_type_be(targetTypeId));
  return NULL;        
}

Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod)
{
  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
  Oid     typinput = typform->typinput;
  Oid     typioparam = getTypeIOParam(tp);
  //调用函数进行转换
  return OidInputFunctionCall(typinput, string, typioparam, atttypmod);
}

Datum
OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
{
  FmgrInfo  flinfo;
  //构造函数调用参数
  fmgr_info(functionId, &flinfo);
  return InputFunctionCall(&flinfo, str, typioparam, typmod);
}

Datum
InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
{
  LOCAL_FCINFO(fcinfo, 3);
  Datum   result;
  if (str == NULL && flinfo->fn_strict)
    return (Datum) 0;   
  InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
  fcinfo->args[0].value = CStringGetDatum(str);
  fcinfo->args[0].isnull = false;
  fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
  fcinfo->args[1].isnull = false;
  fcinfo->args[2].value = Int32GetDatum(typmod);
  fcinfo->args[2].isnull = false;
  //调用函数
  result = FunctionCallInvoke(fcinfo);
  
  if (str == NULL)
  {
    if (!fcinfo->isnull)
      elog(ERROR, "input function %u returned non-NULL",
         flinfo->fn_oid);
  }
  else
  {
    if (fcinfo->isnull)
      elog(ERROR, "input function %u returned NULL",
         flinfo->fn_oid);
  }
  return result;
}

Datum
int4in(PG_FUNCTION_ARGS)
{
  char     *num = PG_GETARG_CSTRING(0);
  PG_RETURN_INT32(pg_strtoint32(num));
}

int32
pg_strtoint32(const char *s)
{
  const char *ptr = s;
  int32   tmp = 0;
  bool    neg = false;
  
  while (likely(*ptr) && isspace((unsigned char) *ptr))
    ptr++;
  
  if (*ptr == '-')
  {
    ptr++;
    neg = true;
  }
  else if (*ptr == '+')
    ptr++;
  
  if (unlikely(!isdigit((unsigned char) *ptr)))
    Goto invalid_syntax;
  
  while (*ptr && isdigit((unsigned char) *ptr))//如'123',-1->-12->-123
  {
    int8    digit = (*ptr++ - '0');//获取数字
    if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||//tmp*10
      unlikely(pg_sub_s32_overflow(tmp, digit, &tmp)))//tmp - digit
      goto out_of_range;
  }
  
  while (*ptr != '\0' && isspace((unsigned char) *ptr))
    ptr++;
  if (unlikely(*ptr != '\0'))
    goto invalid_syntax;
  if (!neg)
  {
    
    if (unlikely(tmp == PG_INT32_MIN))
      goto out_of_range;
    tmp = -tmp;//符号取反,-123->123
  }
  return tmp;
out_of_range:
  ereport(ERROR,
      (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
       errmsg("value \"%s\" is out of range for type %s",
          s, "integer")));
invalid_syntax:
  ereport(ERROR,
      (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
       errmsg("invalid input syntax for type %s: \"%s\"",
          "integer", s)));
  return 0;     
}

三、跟踪分析

SQL脚本

testdb=# select * from t_conv where id = '1';

跟踪分析

(gdb) b coerce_type
Breakpoint 1 at 0x6055f0: file parse_coerce.c, line 164.
(gdb) c
Continuing.
Breakpoint 1, coerce_type (pstate=0x2c89e30, node=0x2c8a678, inputTypeId=705, targetTypeId=23, targetTypeMod=-1, 
    ccontext=COERCION_IMPLICIT, cformat=COERCE_IMPLICIT_CAST, location=-1) at parse_coerce.c:164
164   if (targetTypeId == inputTypeId ||
(gdb)

输入参数,输入类型ID为705(unknown),目标类型为23(int4)

(gdb) p *pstate
$1 = {parentParseState = 0x0, p_sourcetext = 0x2c88e08 "select * from t_conv where id = '1';", p_rtable = 0x2c8a2a0, 
  p_joinexprs = 0x0, p_joinlist = 0x2c8a3a8, p_namespace = 0x2c8a328, p_lateral_active = false, p_ctenamespace = 0x0, 
  p_future_ctes = 0x0, p_parent_cte = 0x0, p_target_relation = 0x0, p_target_rangetblentry = 0x0, p_is_insert = false, 
  p_windowdefs = 0x0, p_expr_kind = EXPR_KIND_WHERE, p_next_resno = 2, p_multiassign_exprs = 0x0, p_locking_clause = 0x0, 
  p_locked_from_parent = false, p_resolve_unknowns = true, p_queryEnv = 0x0, p_hasAggs = false, p_hasWindowFuncs = false, 
  p_hasTargetSRFs = false, p_hasSubLinks = false, p_hasModifyinGCTE = false, p_last_srf = 0x0, p_pre_columnref_hook = 0x0, 
  p_post_columnref_hook = 0x0, p_paramref_hook = 0x0, p_coerce_param_hook = 0x0, p_ref_hook_state = 0x0}
(gdb) p *node
$2 = {type = T_Const}
(gdb) p *(Const *)node
$3 = {xpr = {type = T_Const}, consttype = 705, consttypmod = -1, constcollid = 0, constlen = -2, constvalue = 46701384, 
  constisnull = false, constbyval = false, location = 32}
(gdb) x/1cb 46701384
0x2c89b48:  49 '1'
(gdb)

进入常量转换分支

(gdb) n
170   if (targetTypeId == ANYOID ||
(gdb) 
171     targetTypeId == ANYELEMENTOID ||
(gdb) 
188   if (targetTypeId == ANYARRAYOID ||
(gdb) 
189     targetTypeId == ANYENUMOID ||
(gdb) 
225   if (inputTypeId == UNKNOWNOID && IsA(node, Const))
(gdb) 
244     Const    *con = (Const *) node;
(gdb) 
245     Const    *newcon = makeNode(Const);
(gdb) 
260     baseTypeMod = targetTypeMod;
(gdb) p *con
$4 = {xpr = {type = T_Const}, consttype = 705, consttypmod = -1, constcollid = 0, constlen = -2, constvalue = 46701384, 
  constisnull = false, constbyval = false, location = 32}
(gdb) n
261     baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
(gdb) 
272     if (baseTypeId == INTERVALOID)
(gdb) 
275       inputTypeMod = -1;
(gdb) 
277     baseType = typeidType(baseTypeId);
(gdb) 
279     newcon->consttype = baseTypeId;
(gdb) 
280     newcon->consttypmod = inputTypeMod;
(gdb) 
281     newcon->constcollid = typeTypeCollation(baseType);
(gdb) 
282     newcon->constlen = typeLen(baseType);
(gdb) 
283     newcon->constbyval = typeByVal(baseType);
(gdb) 
284     newcon->constisnull = con->constisnull;
(gdb) 
291     newcon->location = con->location;
(gdb) 
297     setup_parser_errposition_callback(&pcbstate, pstate, con->location);
(gdb) p  *newcon
$5 = {xpr = {type = T_Const}, consttype = 23, consttypmod = -1, constcollid = 0, constlen = 4, constvalue = 0, 
  constisnull = false, constbyval = true, location = 32}
(gdb)

完成转换

(gdb) n
303     if (!con->constisnull)
(gdb) 
305                          DatumGetCString(con->constvalue),
(gdb) 
304       newcon->constvalue = stringTypeDatum(baseType,
(gdb) 
317     if (!con->constisnull && newcon->constlen == -1)
(gdb) 
349     cancel_parser_errposition_callback(&pcbstate);
(gdb) 
351     result = (Node *) newcon;
(gdb) p *newcon
$6 = {xpr = {type = T_Const}, consttype = 23, consttypmod = -1, constcollid = 0, constlen = 4, constvalue = 1, 
  constisnull = false, constbyval = true, location = 32}
(gdb) n
354     if (baseTypeId != targetTypeId)
(gdb) 
361     ReleaseSysCache(baseType);
(gdb) 
363     return result;
(gdb)

转换的实现
跟踪InputFunctionCall

(gdb) b InputFunctionCall
Breakpoint 2 at 0xa6fabe: file fmgr.c, line 1533.
(gdb) c
Continuing.
Breakpoint 2, InputFunctionCall (flinfo=0x7ffd8b1da1f0, str=0x2c89b48 "1", typioparam=23, typmod=-1) at fmgr.c:1533
1533    LOCAL_FCINFO(fcinfo, 3);
(gdb) n
1536    if (str == NULL && flinfo->fn_strict)
(gdb) 
1539    InitFunctionCallInfoData(*fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
(gdb) 
1541    fcinfo->args[0].value = CStringGetDatum(str);
(gdb) 
1542    fcinfo->args[0].isnull = false;
(gdb) 
1543    fcinfo->args[1].value = ObjectIdGetDatum(typioparam);
(gdb) 
1544    fcinfo->args[1].isnull = false;
(gdb) 
1545    fcinfo->args[2].value = Int32GetDatum(typmod);
(gdb) 
1546    fcinfo->args[2].isnull = false;
(gdb) 
1548    result = FunctionCallInvoke(fcinfo);
(gdb) p *fcinfo
$7 = {flinfo = 0x7ffd8b1da1f0, context = 0x0, resultinfo = 0x0, fncollation = 0, isnull = false, nargs = 3, 
  args = 0x7ffd8b1da180}
(gdb) p *fcinfo->flinfo
$8 = {fn_addr = 0x9694fc <int4in>, fn_oid = 42, fn_nargs = 1, fn_strict = true, fn_retset = false, fn_stats = 2 '\002', 
  fn_extra = 0x0, fn_mcxt = 0x2c88cf0, fn_expr = 0x0}
(gdb)

实现函数是int4in->pg_strtoint32

(gdb) b pg_strtoint32
Breakpoint 3 at 0x9b8b45: file numutils.c, line 201.
(gdb) c
Continuing.
Breakpoint 3, pg_strtoint32 (s=0x2c89b48 "123") at numutils.c:201
201   const char *ptr = s;
(gdb) n
202   int32   tmp = 0;
(gdb) 
203   bool    neg = false;
(gdb) 
206   while (likely(*ptr) && isspace((unsigned char) *ptr))
(gdb) 
210   if (*ptr == '-')
(gdb) 
215   else if (*ptr == '+')
(gdb) 
219   if (unlikely(!isdigit((unsigned char) *ptr)))
(gdb) 
223   while (*ptr && isdigit((unsigned char) *ptr))
(gdb) 
225     int8    digit = (*ptr++ - '0');
(gdb) 
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p digit
$9 = 1 '\001'
(gdb) n
228       unlikely(pg_sub_s32_overflow(tmp, digit, &tmp)))
(gdb) p tmp
$10 = 0
(gdb) n
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p tmp
$11 = -1
(gdb) n
223   while (*ptr && isdigit((unsigned char) *ptr))
(gdb) p tmp
$12 = -1
(gdb) n
225     int8    digit = (*ptr++ - '0');
(gdb) 
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p digit
$13 = 2 '\002'
(gdb) n
228       unlikely(pg_sub_s32_overflow(tmp, digit, &tmp)))
(gdb) 
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p tmp
$14 = -12
(gdb) n
223   while (*ptr && isdigit((unsigned char) *ptr))
(gdb) 
225     int8    digit = (*ptr++ - '0');
(gdb) 
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p digit
$15 = 3 '\003'
(gdb) n
228       unlikely(pg_sub_s32_overflow(tmp, digit, &tmp)))
(gdb) 
227     if (unlikely(pg_mul_s32_overflow(tmp, 10, &tmp)) ||
(gdb) p tmp
$16 = -123
(gdb) n
223   while (*ptr && isdigit((unsigned char) *ptr))
(gdb) 
233   while (*ptr != '\0' && isspace((unsigned char) *ptr))
(gdb) 
236   if (unlikely(*ptr != '\0'))
(gdb) 
239   if (!neg)
(gdb) 
242     if (unlikely(tmp == PG_INT32_MIN))
(gdb) p tmp
$17 = -123
(gdb) n
244     tmp = -tmp;
(gdb) 
247   return tmp;

到此,相信大家对“怎么实现PostgreSQL中的类型转换”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

您可能感兴趣的文档:

--结束END--

本文标题: 怎么实现PostgreSQL中的类型转换

本文链接: https://www.lsjlt.com/news/63884.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 怎么实现PostgreSQL中的类型转换
    本篇内容主要讲解“怎么实现PostgreSQL中的类型转换”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么实现PostgreSQL中的类型转换”吧!解析表达式...
    99+
    2022-10-18
  • C++中怎么实现类型转换
    本篇文章给大家分享的是有关C++中怎么实现类型转换,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。0. 类型转换的原理在进行下面的学习前,我觉得有比较知道不同类型是怎么进行转换的...
    99+
    2023-06-20
  • sql server中怎么实现类型转换
    sql server中怎么实现类型转换,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。记录下 :DECLARE @i  INT;DEC...
    99+
    2022-10-18
  • php image类型怎么实现转换
    本文操作环境:Windows7系统,PHP7.1版,Dell G3电脑。php image类型怎么实现转换?php图片格式转换方法 function image_change($image_path, $to_ext = 'png&...
    99+
    2015-05-09
    php image
  • golang interface类型转换怎么实现
    在Go语言中,可以通过类型断言来实现接口类型的转换。 使用类型断言的语法为: value, ok := interfaceVar.(...
    99+
    2023-10-20
    golang
  • SqlServer中怎么实现数据类型转换
    SqlServer中怎么实现数据类型转换,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。SQL中的cast 和convert都是...
    99+
    2022-10-18
  • PostgreSQL的数据类型转换规则是什么
    本篇内容介绍了“PostgreSQL的数据类型转换规则是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!...
    99+
    2022-10-18
  • java怎么实现数据类型的转换
    在Java中,可以使用类型转换操作符将一种数据类型转换成另一种数据类型。类型转换分为两种:隐式类型转换和显式类型转换。1. 隐式类型...
    99+
    2023-10-09
    java
  • PHP类型的隐式转换怎么实现
    本篇内容主要讲解“PHP类型的隐式转换怎么实现”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“PHP类型的隐式转换怎么实现”吧!一、基本数据类型在PHP中,基本数据类型有四种,分别是整型(int)...
    99+
    2023-07-05
  • java怎么实现将Object类型转换为int类型
    这篇文章主要介绍“java怎么实现将Object类型转换为int类型”,在日常操作中,相信很多人在java怎么实现将Object类型转换为int类型问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”java怎么实...
    99+
    2023-06-20
  • python强制类型转换怎么实现
    在Python中,可以使用内置的几个函数来实现强制类型转换,具体取决于要转换的数据类型。以下是一些常用的类型转换函数:1. int(...
    99+
    2023-10-19
    python
  • php怎么实现强制类型转换
    这篇文章主要介绍“php怎么实现强制类型转换”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“php怎么实现强制类型转换”文章能帮助大家解决问题。强制转换方法:1、在要转换的变量前加上用括号括起来的目标...
    99+
    2023-06-30
  • SQL Server中怎么实现数据类型转换
    这篇文章将为大家详细讲解有关SQL Server中怎么实现数据类型转换,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。1 显式转换显示转换是将某种数据类型的表...
    99+
    2022-10-18
  • java如何实现类型转换与强制类型转换
    这篇文章主要介绍了java如何实现类型转换与强制类型转换,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。java类型转换与强制类型转换如果你以前有编程经验,那么你已经知道把一种...
    99+
    2023-06-03
  • PostgreSQL中的bool类型转换为smallint的方法是什么
    这篇文章主要介绍“PostgreSQL中的bool类型转换为smallint的方法是什么”,在日常操作中,相信很多人在PostgreSQL中的bool类型转换为smallint的方法是什么问题上存在疑惑,小...
    99+
    2022-10-18
  • PostgreSQL隐式类型转换中选择操作符的实现函数是什么
    这篇文章主要讲解了“PostgreSQL隐式类型转换中选择操作符的实现函数是什么”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“PostgreSQL隐式类型转...
    99+
    2022-10-18
  • Pandas类型转换astype()的实现
    Python中和Pandas中数据类型对应关系如下: 果数据是纯净的数据,可以转化为数字astype基本也就是两种用作,数字转化为单纯字符串,单纯数字的字符串转化为数字,含有其他的...
    99+
    2022-11-11
  • Java中怎么实现基本数据类型转换
    这期内容当中小编将会给大家带来有关Java中怎么实现基本数据类型转换,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。自动类型转换自动类型转换是指:数字表示范围小的数据类型可以自动转换成范围大的数据类型。如:...
    99+
    2023-06-17
  • PostgreSQL隐式类型转换中使用哪些操作符实现函数
    这篇文章主要讲解了“PostgreSQL隐式类型转换中使用哪些操作符实现函数”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“PostgreSQL隐式类型转换中...
    99+
    2022-10-18
  • PostgreSQL的数据类型转换规则有哪些
    这篇文章主要介绍“PostgreSQL的数据类型转换规则有哪些”,在日常操作中,相信很多人在PostgreSQL的数据类型转换规则有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大...
    99+
    2022-10-18
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作