blob.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**************************************************************************
  2. *
  3. * Licensed Materials - Property of IBM and/or HCL
  4. *
  5. * IBM Informix Dynamic Server
  6. * Copyright IBM Corporation 1996, 2016
  7. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  8. *
  9. ***************************************************************************
  10. *
  11. * Title: blob.h
  12. *
  13. * Description: 'blob.h' defines stuff for blobs
  14. *
  15. ***************************************************************************
  16. */
  17. #ifndef BLOB_DOT_H /* To handle multiple includes */
  18. #define BLOB_DOT_H
  19. #include "ifxtypes.h"
  20. /*
  21. * Structure of the BlobLocation
  22. */
  23. /*
  24. * blob definitions
  25. * tblob_t is the data that is stored in the tuple - it describes the blob
  26. * NOTE: tb_fd is expected to be the first member and TB_FLAGS gives offset
  27. * to the tb_flags member.
  28. */
  29. typedef struct tblob
  30. {
  31. int2 tb_fd; /* blob file descriptor (must be first) */
  32. int2 tb_coloff; /* Blob column offset in row */
  33. int4 tb_tblspace; /* blob table space */
  34. int4 tb_start; /* starting byte */
  35. int4 tb_end; /* ending byte-0 for end of blob */
  36. int4 tb_size; /* Size of blob */
  37. int4 tb_addr; /* Starting Sector or BlobPage */
  38. int4 tb_family; /* Family ID */
  39. int4 tb_volume; /* Family Volume */
  40. int2 tb_medium; /* Medium - odd if removable */
  41. uint2 tb_bstamp; /* first BlobPage Blob stamp */
  42. int2 tb_sockid; /* socket id of remote blob */
  43. int2 tb_flags; /* flags - see below */
  44. int4 tb_reserved1; /* blob compression-original size */
  45. int4 tb_reserved2; /* used tb_lockid */
  46. int4 tb_reserved3; /* used tb_threadid */
  47. int4 tb_reserved4; /* blob compression-compressed size */
  48. } tblob_t;
  49. #ifdef OPTICAL
  50. /**
  51. * for optical blobs, the system id (of the system where the blob was
  52. * created) is stored in the blob descriptor
  53. **/
  54. #define tb_sysid tb_reserved1
  55. #endif /* OPTICAL */
  56. /*
  57. * for alien blobs a lock id for fragmented tables is required since only a
  58. * single fragment of the table is being opened
  59. */
  60. #define tb_lockid tb_reserved2
  61. /*
  62. * used by PDQ to determine if the blob row was read by the same thread the
  63. * blob is being retrieved by
  64. */
  65. #define tb_threadid tb_reserved3
  66. /*
  67. * for identifying the level of the blob. This filed is the partition
  68. * number of the labeld tablespace, which indicates the level of tuple blob.
  69. */
  70. #define tb_label tb_reserved4
  71. /* for compression
  72. */
  73. #define tb_cmp_len tb_reserved4
  74. #define TB_TBLSPACE (2*INTSIZE)
  75. #define TB_FAMILY (2*INTSIZE+5*LONGSIZE)
  76. #define TB_VOLUME (2*INTSIZE+6*LONGSIZE)
  77. #define TB_FLAGS (2*INTSIZE+7*LONGSIZE+3*INTSIZE)
  78. #define TB_RESERV2 (2*INTSIZE+7*LONGSIZE+4*INTSIZE+LONGSIZE)
  79. #define SIZTBLOB (11*LONGSIZE + 6*INTSIZE)
  80. /* 'flags' definitions */
  81. #define BLOBISNULL (0x0001) /* BLOB is NULL */
  82. #define BLOBALIEN (0x0002) /* BLOB is ALIEN */
  83. #define BL_BSBLOB (0x0004) /* blob is stored in blobspace */
  84. #define BL_PNBLOB (0x0008) /* store in tablespace */
  85. #define BL_DESCRIPTOR (0x0010) /* optical BLOB descriptor */
  86. #define BL_CACHE (0x0040) /* blob reside in optical cache */
  87. #define BL_FLUSH (0x0080) /* blob didn't fit in cache */
  88. #define BL_ISVALID(f) \
  89. (f & (BLOBISNULL|BLOBALIEN|BL_BSBLOB| \
  90. BL_PNBLOB|BL_DESCRIPTOR|BL_CACHE|BL_FLUSH))
  91. #define BL_LOCALBLOB (0x0040) /* "remote" blob is actually local */
  92. #ifdef CDR
  93. #define BL_NOCHANGE (0x0100) /* blob unchanged after row update */
  94. #endif /* CDR */
  95. #define BL_LOG_ADDR (0x0200) /* tb_addr is logical address */
  96. /* only valid on blobspace blobs */
  97. #define BL_FASTPATH (0x0400) /* blob descriptor from fastpath */
  98. #define BL_SMLDTASZ (0x0800) /* blob size is smldtasz < 32K */
  99. #define BL_COMPRESSED (0x1000) /* Partition blob is compressed */
  100. #define BL_SKIPCOPY (0x2000) /* skip blob copy for load from
  101. * External table. In-memory flag
  102. * only (not stored on disk).
  103. */
  104. #define BL_TEXT (0x4000) /* used in sql/drda layer */
  105. #define BL_BYTE ((uint2)0x8000) /* used in sql/drda layer */
  106. /* Get the length of a (possibly subscripted) blob.
  107. * "tb_size" is the unsubscripted full blob size.
  108. * This macro shall be used in place of tb_size whenever
  109. * subscription is semantically allowed.
  110. * The input shall be a tblob_t pointer.
  111. * See "case BL_DBTABLE" in fmsend_blobs() for more info.
  112. * NOTE: This macro does NOT handle null blobs. Caller must handle nulls separately.
  113. */
  114. #define GET_BLOB_LEN(tbp) \
  115. ( \
  116. (tbp)->tb_start == 0 ? \
  117. (tbp)->tb_size : \
  118. ( \
  119. (tbp)->tb_start == 1 && (tbp)->tb_end == 0 ? \
  120. 0: \
  121. (tbp)->tb_end - (tbp)->tb_start + 1 \
  122. ) \
  123. )
  124. /*
  125. * this struture is used to pass "useful" information back to
  126. * the user.
  127. */
  128. typedef struct blobinfo
  129. {
  130. int4 bi_size; /* Size of blob */
  131. int4 bi_addr; /* Starting Sector or BlobPage */
  132. int4 bi_family; /* Family ID */
  133. int4 bi_volume; /* Family Volume */
  134. int2 bi_flags; /* flags */
  135. int2 bi_medium; /* Medium - odd if removable */
  136. } blobinfo_t;
  137. #endif /* BLOB_DOT_H : To handle multiple includes */