Skip to main content

Posts

Showing posts from May, 2012

PostgreSQL PL/C Functions

Hi , Here is my first PL/C Function. Find the Steps How to create and implement.  Step 1 ====== -bash-3.2$ pwd /opt/PostgresPlus/9.0AS -bash-3.2$ more concat_text.c #include "postgres.h" #include "fmgr.h" #include <string.h> #include <unistd.h> #ifdef PG_MODULE_MAGIC PG_MODULE_MAGIC; #endif PG_FUNCTION_INFO_V1(concat_text); Datum concat_text(PG_FUNCTION_ARGS) {     text  *arg1 = PG_GETARG_TEXT_P(0);     text  *arg2 = PG_GETARG_TEXT_P(1);     int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;     text *new_text = (text *) palloc(new_text_size);     system("touch /tmp/table.txt");     SET_VARSIZE (new_text,new_text_size);     memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ);     memcpy(VARDATA(new_text) + (VARSIZE(arg1) - VARHDRSZ),            VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ);     PG_RETURN_TEXT_P(new_text); } Step 2 ======= -bash-3.2$ more Makefile PG_CONFIG = /opt/PostgresPlus/9.0AS

How to parse multiple lines using strtok()

Hi, Here is the sample C program which parse the lines using strtok() function. strtok() behaves very strange way and we need to take care of that.  Here is the file i need to parse ======================== [root@localhost PGBAR]# more /tmp/.cred.txt [PGM]Host:127.0.0.1:Port:5434:User:postgres:Database:pgm:Password:postgres [MONITOR]Host:127.0.0.1:Port:5434:User:postgres:Database:postgres:Password:postgres [MONITOR]Host:127.0.0.1:Port:5434:User:postgres:Database:postgres:Password:postgres Here is the C Program written to parse the above lines and need to give the Postgresql Connection String.  #include<stdio.h> #include<string.h> int Check_Token(char *Token,char *Compare) { if(strcmp(Token,Compare)!=0) { fprintf(stderr,"Invalid Identifier %s %s",Token,Compare); return 0; } return 1; } int Framing_Connection_String(char Line[]) { char Conn_String[100],*Host,*Port,*Database,*User,*Password,*Search; Search=strstr(Line,&

Heterogeneous DB Connection Between Oracle And Postgres Plus

Hi , Finally,i have configured the heterogeneous (HS) Database Connectivity between Oracle 11.2 and PPAS 9.1. I believe, the same steps will be suitable for the PostgreSQL as well. Please find the steps one by one . Step 1:- -------- We need to Configure the odbcinst.ini file which is having all the Drivers Information. [enterprisedb] Description=PostgresPlus Advanced Server ODBC driver Driver=/opt/PostgresPlus/9.1AS/connectors/odbc/lib/edb-odbc.so Setup=/opt/PostgresPlus/9.1AS/connectors/odbc/lib/libodbcedbS.so UsageCount=1 Step 2:- -------- We need to Configure the odbc.ini file which is having all the DNS entries. [edb] Driver=enterprisedb Description=Connection to LDAP/POSTGRESQL Servername=localhost    Port=5444 Protocol=7.4 FetchBufferSize=99 Username=enterprisedb Password=adminedb Database=edb ReadOnly=no Debug=1 Trace = yes CommLog=1 UseDeclareFetch=0 TraceFile=/tmp/sql.log UseServerSidePrepare=1 dbms_name=PostgreSQL Step 3:- --------- Check the DNS Connectivity [root

Directory Default Permissions In Linux

Hi All, Find the below steps to give the default permissions on the creating files or folders on fly.  Step 1 ------- [root@CentOS62STM64bit test_dir]# useradd test_user [root@CentOS62STM64bit test_dir]# passwd test_user Step 2 ------ groupadd test_group Step 3 ------ [root@CentOS62STM64bit test_dir]# usermod -G test test_user Step 4 ------ [root@CentOS62STM64bit test_dir]# su - test_user [test_user@CentOS62STM64bit ~]$ mkdir test Step 5 ------ [test_user@CentOS62STM64bit ~]$ chgrp -R test_group test/ Step 6 ------ [test_user@CentOS62STM64bit test]$ setfacl -d -m u::rwx,g::rwx,o::rwx test/ Step 7 ------ [test_user@CentOS62STM64bit test]$ touch abcd Step 8 ------ [test_user@CentOS62STM64bit test]$ ls -lrth rw-rw-rw. 1 test_user test_user 0 Apr 30 23:48 abcd --Dinesh