diff -u -r ../postgresql-snapshot/src/backend/utils/adt/nabstime.c ../pgsql/src/backend/utils/adt/nabstime.c
--- ../postgresql-snapshot/src/backend/utils/adt/nabstime.c 2003-05-13 07:08:50.000000000 +0800
+++ ../pgsql/src/backend/utils/adt/nabstime.c 2003-07-15 11:08:06.000000000 +0800
@@ -76,7 +76,6 @@
* Function prototypes -- internal to this file only
*/

-static AbsoluteTime tm2abstime(struct tm * tm, int tz);
static void reltime2tm(RelativeTime time, struct tm * tm);
static int istinterval(char *i_string,
AbsoluteTime *i_start,
@@ -311,7 +310,7 @@
* Convert a tm structure to abstime.
* Note that tm has full year (not 1900-based) and 1-based month.
*/
-static AbsoluteTime
+AbsoluteTime
tm2abstime(struct tm * tm, int tz)
{
int day;
diff -u -r ../postgresql-snapshot/src/backend/utils/adt/timestamp.c ../pgsql/src/backend/utils/adt/timestamp.c
--- ../postgresql-snapshot/src/backend/utils/adt/timestamp.c 2003-05-13 07:08:50.000000000 +0800
+++ ../pgsql/src/backend/utils/adt/timestamp.c 2003-07-15 20:42:39.000000000 +0800
@@ -847,7 +847,65 @@
result = AbsoluteTimeUsecToTimestampTz(sec, usec);

        PG_RETURN_TIMESTAMPTZ(result);
-}
+}      /* now() */
+
+/*
+ * Function transaction_timestamp() return current transaction timestamp.
+ * Added by Xiongjian Wang (MikeWang)
+*/
+Datum
+transaction_timestamp(PG_FUNCTION_ARGS)
+{
+       TimestampTz result;
+       AbsoluteTime sec;
+       int                     usec;
+
+       sec = GetCurrentTransactionStartTimeUsec(&usec);
+
+       result = AbsoluteTimeUsecToTimestampTz(sec, usec);
+
+       PG_RETURN_TIMESTAMPTZ(result);
+}      /* transaction_timestamp() */
+
+/*
+ * Function clock_timestamp() return current clock timestamp.
+ * Added by Xiongjian Wang (MikeWang)
+*/
+Datum
+clock_timestamp(PG_FUNCTION_ARGS)
+{
+       TimestampTz result;
+       AbsoluteTime sec;
+       int                     usec;
+
+       sec = GetCurrentAbsoluteTimeUsec(&usec);
+
+       result = AbsoluteTimeUsecToTimestampTz(sec, usec);
+
+       PG_RETURN_TIMESTAMPTZ(result);
+}      /* clock_timestamp() */
+
+Datum
+transaction_interval(PG_FUNCTION_ARGS)
+{
+       Timestamp trans_tz;
+       Timestamp clock_tz;
+       
+       AbsoluteTime trans_sec;
+       AbsoluteTime clock_sec;
+       int trans_usec;
+       int clock_usec;
+
+       clock_sec = GetCurrentAbsoluteTimeUsec(&clock_usec);
+       trans_sec = GetCurrentTransactionStartTimeUsec(&trans_usec);
+
+       trans_tz = AbsoluteTimeUsecToTimestampTz(trans_sec, trans_usec);
+       clock_tz = AbsoluteTimeUsecToTimestampTz(clock_sec, clock_usec);
+
+       return DirectFunctionCall2(timestamp_mi,
+                                                          TimestampGetDatum(clock_tz),
+                                                          
TimestampGetDatum(trans_tz));
+}      /* transaction_interval() */

void
dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
diff -u -r ../postgresql-snapshot/src/include/catalog/pg_proc.h ../pgsql/src/include/catalog/pg_proc.h
--- ../postgresql-snapshot/src/include/catalog/pg_proc.h 2003-06-23 06:04:55.000000000 +0800
+++ ../pgsql/src/include/catalog/pg_proc.h 2003-07-15 20:54:06.000000000 +0800
@@ -3394,6 +3394,15 @@
DATA(insert OID = 2503 ( anyarray_send PGNSP PGUID 12 f f t f s 1 17 "2277" anyarray_send - _null_ ));
DESCR("I/O");

+/* Added by Xiongjian Wang (MikeWang) */
+DATA(insert OID = 5001 ( transaction_timestamp PGNSP PGUID 12 f f t f s 0 1184 "" transaction_timestamp - _null_ ));
+DESCR("current transaction timestamp like as function now()");
+
+DATA(insert OID = 5002 ( clock_timestamp PGNSP PGUID 12 f f t f v 0 1184 "" clock_timestamp - _null_ ));
+DESCR("current clock timestamp");
+
+DATA(insert OID = 5003 ( transaction_interval PGNSP PGUID 12 f f t f v 0 1186 "" transaction_interval - _null_ ));
+DESCR("current transaction runs into present interval");

/*
* Symbolic values for provolatile column: these indicate whether the result
diff -u -r ../postgresql-snapshot/src/include/utils/nabstime.h ../pgsql/src/include/utils/nabstime.h
--- ../postgresql-snapshot/src/include/utils/nabstime.h 2003-05-13 07:08:52.000000000 +0800
+++ ../pgsql/src/include/utils/nabstime.h 2003-07-15 11:06:41.000000000 +0800
@@ -165,5 +165,5 @@
extern AbsoluteTime GetCurrentAbsoluteTimeUsec(int *usec);
extern TimestampTz AbsoluteTimeUsecToTimestampTz(AbsoluteTime sec, int usec);
extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char **tzn);
-
+extern AbsoluteTime tm2abstime(struct tm * tm, int tz);
#endif /* NABSTIME_H */
diff -u -r ../postgresql-snapshot/src/include/utils/timestamp.h ../pgsql/src/include/utils/timestamp.h
--- ../postgresql-snapshot/src/include/utils/timestamp.h 2003-05-13 07:08:52.000000000 +0800
+++ ../pgsql/src/include/utils/timestamp.h 2003-07-15 20:44:35.000000000 +0800
@@ -233,20 +233,24 @@

extern Datum now(PG_FUNCTION_ARGS);

-/* Internal routines (not fmgr-callable) */
+/* Add by Xiongjian Wang (Mike Wang) */
+extern Datum transaction_timestamp(PG_FUNCTION_ARGS);
+extern Datum clock_timestamp(PG_FUNCTION_ARGS);
+extern Datum transaction_interval(PG_FUNCTION_ARGS);

-extern int tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
+/* Internal routines (not fmgr-callable) */
+extern int tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);
extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
fsec_t *fsec, char **tzn);
extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec);

-extern int     interval2tm(Interval span, struct tm * tm, fsec_t *fsec);
-extern int     tm2interval(struct tm * tm, fsec_t fsec, Interval *span);
+extern int interval2tm(Interval span, struct tm * tm, fsec_t *fsec);
+extern int tm2interval(struct tm * tm, fsec_t fsec, Interval *span);

extern Timestamp SetEpochTimestamp(void);
extern void GetEpochTime(struct tm * tm);

extern void isoweek2date(int woy, int *year, int *mon, int *mday);
-extern int     date2isoweek(int year, int mon, int mday);
+extern int date2isoweek(int year, int mon, int mday);

#endif /* TIMESTAMP_H */

-------------------------------------------------------------------

or see my attachment .

and I have a problem, what is stetement_timestamp() ??

_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn/

Attachment: timestamp.diff
Description: Binary data

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to