[Groonga-commit] pgroonga/pgroonga at 2a558a7 [master] pgroonga.table_name: change return type to text from cstring

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Nov 29 23:46:56 JST 2016


Kouhei Sutou	2016-11-29 23:46:56 +0900 (Tue, 29 Nov 2016)

  New Revision: 2a558a73c8206288cda04c96b1232c01c0e27d58
  https://github.com/pgroonga/pgroonga/commit/2a558a73c8206288cda04c96b1232c01c0e27d58

  Message:
    pgroonga.table_name: change return type to text from cstring
    
    Because text is useful than cstring on passing return value to other
    function.

  Modified files:
    pgroonga--1.1.8--1.1.9.sql
    pgroonga.sql
    src/pgroonga.c

  Modified: pgroonga--1.1.8--1.1.9.sql (+8 -0)
===================================================================
--- pgroonga--1.1.8--1.1.9.sql    2016-11-29 23:10:01 +0900 (9af407a)
+++ pgroonga--1.1.8--1.1.9.sql    2016-11-29 23:46:56 +0900 (838d0d2)
@@ -1,3 +1,11 @@
+DROP FUNCTION pgroonga.table_name;
+CREATE FUNCTION pgroonga.table_name(indexName cstring)
+	RETURNS text
+	AS 'MODULE_PATHNAME', 'pgroonga_table_name'
+	LANGUAGE C
+	STABLE
+	STRICT;
+
 CREATE FUNCTION pgroonga.command_escape_value(value text)
 	RETURNS text
 	AS 'MODULE_PATHNAME', 'pgroonga_command_escape_value'

  Modified: pgroonga.sql (+1 -1)
===================================================================
--- pgroonga.sql    2016-11-29 23:10:01 +0900 (79d1cc0)
+++ pgroonga.sql    2016-11-29 23:46:56 +0900 (acb3aa9)
@@ -10,7 +10,7 @@ CREATE FUNCTION pgroonga.score("row" record)
 	STRICT;
 
 CREATE FUNCTION pgroonga.table_name(indexName cstring)
-	RETURNS cstring
+	RETURNS text
 	AS 'MODULE_PATHNAME', 'pgroonga_table_name'
 	LANGUAGE C
 	STABLE

  Modified: src/pgroonga.c (+6 -6)
===================================================================
--- src/pgroonga.c    2016-11-29 23:10:01 +0900 (71a362a)
+++ src/pgroonga.c    2016-11-29 23:46:56 +0900 (943c59e)
@@ -1074,7 +1074,7 @@ pgroonga_score(PG_FUNCTION_ARGS)
 #endif
 
 /**
- * pgroonga.table_name(indexName cstring) : cstring
+ * pgroonga.table_name(indexName cstring) : text
  */
 Datum
 pgroonga_table_name(PG_FUNCTION_ARGS)
@@ -1083,8 +1083,8 @@ pgroonga_table_name(PG_FUNCTION_ARGS)
 	Datum indexOidDatum;
 	Oid indexOid;
 	Oid fileNodeOid;
-	char tableName[GRN_TABLE_MAX_KEY_SIZE];
-	char *copiedTableName;
+	char tableNameBuffer[GRN_TABLE_MAX_KEY_SIZE];
+	text *tableName;
 
 	indexOidDatum = DirectFunctionCall1(regclassin, indexNameDatum);
 	if (!OidIsValid(indexOidDatum))
@@ -1113,11 +1113,11 @@ pgroonga_table_name(PG_FUNCTION_ARGS)
 		}
 	}
 
-	snprintf(tableName, sizeof(tableName),
+	snprintf(tableNameBuffer, sizeof(tableNameBuffer),
 			 PGrnSourcesTableNameFormat,
 			 fileNodeOid);
-	copiedTableName = pstrdup(tableName);
-	PG_RETURN_CSTRING(copiedTableName);
+	tableName = cstring_to_text(tableNameBuffer);
+	PG_RETURN_TEXT_P(tableName);
 }
 
 /**
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index