xugusql_result.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package xugu
  2. type xugusqlResult struct {
  3. // Returns the number of rows affected
  4. // by update, delete and other related operations
  5. // 返回受 update、delete 和其他相关操作影响的行数
  6. affectedRows int64
  7. // Returns the GUID number of
  8. // the insert operation (not supported)
  9. // 返回 insert 操作的 GUID 编号(不支持)
  10. insertId int64
  11. }
  12. // LastInsertId returns the integer generated by the database
  13. // in response to a command. Typically this will be from an
  14. // "auto increment" column when inserting a new row. Not all
  15. // databases support this feature, and the syntax of such
  16. // statements varies.
  17. // LastInsertId 返回数据库响应命令生成的整数。
  18. // 通常这是在插入新行时来自“自动递增”列的值。
  19. // 并非所有数据库都支持此功能,且此类语句的语法各不相同。
  20. func (self *xugusqlResult) LastInsertId() (int64, error) {
  21. return self.insertId, nil
  22. }
  23. // RowsAffected returns the number of rows affected by an
  24. // update, insert, or delete. Not every database or database
  25. // driver may support this.
  26. // RowsAffected 返回受 update、insert 或 delete 影响的行数。
  27. // 并非每个数据库或数据库驱动都支持此功能。
  28. func (self *xugusqlResult) RowsAffected() (int64, error) {
  29. return self.affectedRows, nil
  30. }
  31. type FieldInfo struct {
  32. TabName string // 基表名
  33. Name string // 列名
  34. Alias string // 别名
  35. TypeID uint32 // 类型 ID
  36. CTypeID uint32 // ODBC 的 SQL_C_XXX 类型
  37. Modi uint32 // 列修改集合
  38. Flags uint32 // 列标志,用于是否可为空,是否为主键等
  39. Offset uint32 // 列数据偏移量
  40. }
  41. type RhRow struct {
  42. FieldNum int16 // 字段数量
  43. State int16 // 状态
  44. Mbmk [20]byte // 标记
  45. RowData [4]byte // 行数据(长度不固定)
  46. }
  47. type Block struct {
  48. Next *Block // 下一个块指针
  49. BuffSize int // 缓冲区大小
  50. Off int // 偏移量
  51. Res int // 资源
  52. BlkNo int // 块编号(未使用)
  53. RowNo int64 // 行号(未使用)
  54. Data []byte // 数据
  55. }
  56. type Result struct {
  57. Type HANDLE_TYPE // 句柄类型
  58. State int32 // 状态
  59. FieldNum uint32 // 字段数量
  60. ColInfos []FieldInfo // SELECT 返回的结果集列属性信息
  61. RowSize uint32 // 行大小
  62. ICurrPos int32 // 当前行位置
  63. SlotNum int64 // 槽数量
  64. Rows [][][]interface{} // 行数据
  65. RowNum int64 // 记录计数器
  66. CurRec *RhRow // 当前记录
  67. ErrStr string // 错误信息字符串
  68. DbcFlob *xugusqlConn // 数据库连接属性
  69. IsMultiResult bool // 是否多结果集
  70. NextResult *Result // 下一个结果集
  71. PBlokmemls *RSMemStruct // 内存块链表,添加于 2019-05-06
  72. SQLType int // SQL 类型:0 未知, 1 插入, 2 更新, 3 删除, 4 查询, 5 其他, 6 创建, 7 修改, 8 开始, 9 声明, 10 设置
  73. EffectNum int // 更新、删除类型的影响行数
  74. InsertBmk [32]byte // 插入类型的标记
  75. }
  76. type RSMemStruct struct {
  77. Head *Block // 头部块
  78. CurBlok *Block // 当前块
  79. }