From 2cb15807a0a6a23515b5c06940481d50760da93b Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 10 Aug 2025 09:49:46 +0800 Subject: [PATCH] Add ExecStatusType --- ffi/conn.ha | 23 +++++++++++++++++++++++ ffi/result.ha | 22 ++++++++++++++++++++++ ffi/status.ha | 23 ----------------------- diff --git a/ffi/conn.ha b/ffi/conn.ha index 7a4fae81475d5e14ae6a7713217cfc54e0aab7ff..f45bb9374bc8bf924354d2ad831bc441952423ad 100644 --- a/ffi/conn.ha +++ b/ffi/conn.ha @@ -4,3 +4,26 @@ export type conn = opaque; export @symbol("PQconnectdb") fn connectdb(conninfo: const *c::char) *conn; export @symbol("PQfinish") fn finish(conn: *conn) void; +export @symbol("PQstatus") fn status(conn: *conn) ConnStatusType; + +export type ConnStatusType = enum int { + OK, + BAD, + + STARTED, + MADE, + AWAITING_RESPONSE, + + AUTH_OK, + + SETENV, + SSL_STARTUP, + NEEDED, + CHECK_WRITABLE, + CONSUME, + GSS_STARTUP, + CHECK_TARGET, + + CHECK_STANDBY, + ALLOCATED, +}; diff --git a/ffi/result.ha b/ffi/result.ha index 6d1734e0d2a6d515e415e862d4395d6758f90ab3..abae938480bbdf1893cfd3ca1dfdd5441c3da895 100644 --- a/ffi/result.ha +++ b/ffi/result.ha @@ -9,3 +9,25 @@ export @symbol("PQfname") fn fname(res: *result, field_num: int) *c::char; export @symbol("PQntuples") fn ntuples(res: *result) int; export @symbol("PQgetvalue") fn getvalue(res: *result, tup_num: int, field_num: int) *c::char; export @symbol("PQgetlength") fn getlength(res: *result, tup_num: int, field_num: int) int; + +export type ExecStatusType = enum int { + EMPTY_QUERY = 0, + COMMAND_OK, + + TUPLES_OK, + + COPY_OUT, + COPY_IN, + BAD_RESPONSE, + + NONFATAL_ERROR, + FATAL_ERROR, + COPY_BOTH, + SINGLE_TUPLE, + PIPELINE_SYNC, + PIPELINE_ABORTED, + + TUPLES_CHUNK, +}; + +export @symbol("PQresultStatus") fn resultStatus(res: *result) ExecStatusType; diff --git a/ffi/status.ha b/ffi/status.ha deleted file mode 100644 index d5c123726bfb6f03ff5f2f0b9a5700a6d1162fa2..0000000000000000000000000000000000000000 --- a/ffi/status.ha +++ /dev/null @@ -1,23 +0,0 @@ -export @symbol("PQstatus") fn status(conn: *conn) ConnStatusType; - -export type ConnStatusType = enum int { - OK, - BAD, - - STARTED, - MADE, - AWAITING_RESPONSE, - - AUTH_OK, - - SETENV, - SSL_STARTUP, - NEEDED, - CHECK_WRITABLE, - CONSUME, - GSS_STARTUP, - CHECK_TARGET, - - CHECK_STANDBY, - ALLOCATED, -}; -- 2.48.1