@@ -138,27 +138,13 @@ typedef uint16 LOCKMETHODID;
138138typedef enum LockTagType
139139{
140140 LOCKTAG_RELATION , /* whole relation */
141- /* ID info for a relation is DB OID + REL OID; DB OID = 0 if shared */
142141 LOCKTAG_RELATION_EXTEND , /* the right to extend a relation */
143- /* same ID info as RELATION */
144142 LOCKTAG_PAGE , /* one page of a relation */
145- /* ID info for a page is RELATION info + BlockNumber */
146143 LOCKTAG_TUPLE , /* one physical tuple */
147- /* ID info for a tuple is PAGE info + OffsetNumber */
148144 LOCKTAG_TRANSACTION , /* transaction (for waiting for xact done) */
149- /* ID info for a transaction is its TransactionId */
150145 LOCKTAG_VIRTUALTRANSACTION , /* virtual transaction (ditto) */
151- /* ID info for a virtual transaction is its VirtualTransactionId */
152146 LOCKTAG_SPECULATIVE_TOKEN , /* speculative insertion Xid and token */
153- /* ID info for a transaction is its TransactionId */
154147 LOCKTAG_OBJECT , /* non-relation database object */
155- /* ID info for an object is DB OID + CLASS OID + OBJECT OID + SUBID */
156-
157- /*
158- * Note: object ID has same representation as in pg_depend and
159- * pg_description, but notice that we are constraining SUBID to 16 bits.
160- * Also, we use DB OID = 0 for shared objects such as tablespaces.
161- */
162148 LOCKTAG_USERLOCK , /* reserved for old contrib/userlock code */
163149 LOCKTAG_ADVISORY /* advisory user locks */
164150} LockTagType ;
@@ -190,6 +176,8 @@ typedef struct LOCKTAG
190176 * the physical fields of LOCKTAG. Use these to set up LOCKTAG values,
191177 * rather than accessing the fields directly. Note multiple eval of target!
192178 */
179+
180+ /* ID info for a relation is DB OID + REL OID; DB OID = 0 if shared */
193181#define SET_LOCKTAG_RELATION (locktag ,dboid ,reloid ) \
194182 ((locktag).locktag_field1 = (dboid), \
195183 (locktag).locktag_field2 = (reloid), \
@@ -198,6 +186,7 @@ typedef struct LOCKTAG
198186 (locktag).locktag_type = LOCKTAG_RELATION, \
199187 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
200188
189+ /* same ID info as RELATION */
201190#define SET_LOCKTAG_RELATION_EXTEND (locktag ,dboid ,reloid ) \
202191 ((locktag).locktag_field1 = (dboid), \
203192 (locktag).locktag_field2 = (reloid), \
@@ -206,6 +195,7 @@ typedef struct LOCKTAG
206195 (locktag).locktag_type = LOCKTAG_RELATION_EXTEND, \
207196 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
208197
198+ /* ID info for a page is RELATION info + BlockNumber */
209199#define SET_LOCKTAG_PAGE (locktag ,dboid ,reloid ,blocknum ) \
210200 ((locktag).locktag_field1 = (dboid), \
211201 (locktag).locktag_field2 = (reloid), \
@@ -214,6 +204,7 @@ typedef struct LOCKTAG
214204 (locktag).locktag_type = LOCKTAG_PAGE, \
215205 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
216206
207+ /* ID info for a tuple is PAGE info + OffsetNumber */
217208#define SET_LOCKTAG_TUPLE (locktag ,dboid ,reloid ,blocknum ,offnum ) \
218209 ((locktag).locktag_field1 = (dboid), \
219210 (locktag).locktag_field2 = (reloid), \
@@ -222,6 +213,7 @@ typedef struct LOCKTAG
222213 (locktag).locktag_type = LOCKTAG_TUPLE, \
223214 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
224215
216+ /* ID info for a transaction is its TransactionId */
225217#define SET_LOCKTAG_TRANSACTION (locktag ,xid ) \
226218 ((locktag).locktag_field1 = (xid), \
227219 (locktag).locktag_field2 = 0, \
@@ -230,6 +222,7 @@ typedef struct LOCKTAG
230222 (locktag).locktag_type = LOCKTAG_TRANSACTION, \
231223 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
232224
225+ /* ID info for a virtual transaction is its VirtualTransactionId */
233226#define SET_LOCKTAG_VIRTUALTRANSACTION (locktag ,vxid ) \
234227 ((locktag).locktag_field1 = (vxid).backendId, \
235228 (locktag).locktag_field2 = (vxid).localTransactionId, \
@@ -238,6 +231,10 @@ typedef struct LOCKTAG
238231 (locktag).locktag_type = LOCKTAG_VIRTUALTRANSACTION, \
239232 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
240233
234+ /*
235+ * ID info for a speculative insert is TRANSACTION info +
236+ * its speculative insert counter.
237+ */
241238#define SET_LOCKTAG_SPECULATIVE_INSERTION (locktag ,xid ,token ) \
242239 ((locktag).locktag_field1 = (xid), \
243240 (locktag).locktag_field2 = (token), \
@@ -246,6 +243,13 @@ typedef struct LOCKTAG
246243 (locktag).locktag_type = LOCKTAG_SPECULATIVE_TOKEN, \
247244 (locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
248245
246+ /*
247+ * ID info for an object is DB OID + CLASS OID + OBJECT OID + SUBID
248+ *
249+ * Note: object ID has same representation as in pg_depend and
250+ * pg_description, but notice that we are constraining SUBID to 16 bits.
251+ * Also, we use DB OID = 0 for shared objects such as tablespaces.
252+ */
249253#define SET_LOCKTAG_OBJECT (locktag ,dboid ,classoid ,objoid ,objsubid ) \
250254 ((locktag).locktag_field1 = (dboid), \
251255 (locktag).locktag_field2 = (classoid), \
0 commit comments