dbd/postgresql/connection.c

changeset 2
c4f02fc67e5a
parent 1
408291a6eb3e
child 3
b61020ca4753
--- a/dbd/postgresql/connection.c	Sun Nov 23 01:29:09 2008 +0000
+++ b/dbd/postgresql/connection.c	Sun Nov 23 04:12:04 2008 +0000
@@ -2,6 +2,9 @@
 
 int dbd_postgresql_statement_create(lua_State *L, connection_t *conn, const char *sql_query);
 
+/*
+ * connection = DBD.PostgreSQL.New(dbname, user, password, host, port)
+ */
 static int connection_new(lua_State *L) {
     int n = lua_gettop(L);
     connection_t *conn = NULL;
@@ -61,6 +64,9 @@
     return 1;
 }
 
+/*
+ * success = connection:close()
+ */
 static int connection_close(lua_State *L) {
     connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_CONNECTION);
     int disconnect = 0;   
@@ -74,6 +80,9 @@
     return 1;
 }
 
+/*
+ * ok = connection:ping()
+ */
 static int connection_ping(lua_State *L) {
     connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_CONNECTION);
     int ok = 0;   
@@ -89,6 +98,9 @@
     return 1;
 }
 
+/*
+ * statement = connection:prepare(sql_string)
+ */
 static int connection_prepare(lua_State *L) {
     connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_CONNECTION);
 
@@ -100,7 +112,9 @@
     return 1;
 }
 
-
+/*
+ * __gc
+ */
 static int connection_gc(lua_State *L) {
     /* always close the connection */
     connection_close(L);
@@ -108,19 +122,19 @@
     return 0;
 }
 
-static const luaL_Reg connection_methods[] = {
-    {"close", connection_close},
-    {"ping", connection_ping},
-    {"prepare", connection_prepare},
-    {NULL, NULL}
-};
+int dbd_postgresql_connection(lua_State *L) {
+    static const luaL_Reg connection_methods[] = {
+	{"close", connection_close},
+	{"ping", connection_ping},
+	{"prepare", connection_prepare},
+	{NULL, NULL}
+    };
 
-static const luaL_Reg connection_class_methods[] = {
-    {"New", connection_new},
-    {NULL, NULL}
-};
+    static const luaL_Reg connection_class_methods[] = {
+	{"New", connection_new},
+	{NULL, NULL}
+    };
 
-int dbd_postgresql_connection(lua_State *L) {
     luaL_newmetatable(L, DBD_POSTGRESQL_CONNECTION);
     luaL_register(L, 0, connection_methods);
     lua_pushvalue(L,-1);

mercurial